Skip to content

Commit 851f7c1

Browse files
authored
fix: component windows extension (#1567)
1 parent 9019e41 commit 851f7c1

File tree

3 files changed

+30
-5
lines changed

3 files changed

+30
-5
lines changed

lwcomponent/catalog.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,13 @@ func (c *Catalog) Stage(
172172
}
173173

174174
func (c *Catalog) Verify(component *CDKComponent) (err error) {
175-
data, err := os.ReadFile(filepath.Join(component.stage.Directory(), component.Name))
175+
path := filepath.Join(component.stage.Directory(), component.Name)
176+
177+
if operatingSystem == "windows" {
178+
path = fmt.Sprintf("%s.exe", path)
179+
}
180+
181+
data, err := os.ReadFile(path)
176182
if err != nil {
177183
return
178184
}
@@ -215,9 +221,15 @@ func (c *Catalog) Install(component *CDKComponent) (err error) {
215221
return
216222
}
217223

224+
path := filepath.Join(component.stage.Directory(), component.Name)
225+
226+
if operatingSystem == "windows" {
227+
path = fmt.Sprintf("%s.exe", path)
228+
}
229+
218230
if component.ApiInfo != nil &&
219231
(component.ApiInfo.ComponentType == BinaryType || component.ApiInfo.ComponentType == CommandType) {
220-
if err := os.Chmod(filepath.Join(componentDir, component.Name), 0744); err != nil {
232+
if err := os.Chmod(path, 0744); err != nil {
221233
return errors.Wrap(err, "unable to make component executable")
222234
}
223235
}

lwcomponent/host_info.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,13 @@ func (h *HostInfo) Validate() (err error) {
139139
return errors.New(fmt.Sprintf("missing file '%s'", componentName))
140140
}
141141

142-
if !file.FileExists(filepath.Join(h.Dir, componentName)) {
142+
path := filepath.Join(h.Dir, componentName)
143+
144+
if operatingSystem == "windows" {
145+
path = fmt.Sprintf("%s.exe", path)
146+
}
147+
148+
if !file.FileExists(path) {
143149
return errors.New(fmt.Sprintf("missing file '%s'", componentName))
144150
}
145151

lwcomponent/staging.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"archive/tar"
55
"compress/gzip"
66
"encoding/base64"
7+
"fmt"
78
"io"
89
"net/url"
910
"os"
@@ -174,8 +175,14 @@ func (s *stageTarGz) Validate() (err error) {
174175
return errors.Errorf("missing file '%s'", s.name)
175176
}
176177

177-
if !file.FileExists(filepath.Join(s.dir, s.name)) {
178-
return errors.Errorf("missing file '%s'", s.name)
178+
path := filepath.Join(s.dir, s.name)
179+
180+
if operatingSystem == "windows" {
181+
path = fmt.Sprintf("%s.exe", path)
182+
}
183+
184+
if !file.FileExists(path) {
185+
return errors.Errorf("missing file '%s'", path)
179186
}
180187

181188
return

0 commit comments

Comments
 (0)