diff --git a/internal/pipe/winget/testdata/TestRunPipe/wrapped-in-dir/wrapped-in-dir.installer.yaml.golden b/internal/pipe/winget/testdata/TestRunPipe/wrapped-in-dir/wrapped-in-dir.installer.yaml.golden index 77a8372fe..68f2d1a56 100644 --- a/internal/pipe/winget/testdata/TestRunPipe/wrapped-in-dir/wrapped-in-dir.installer.yaml.golden +++ b/internal/pipe/winget/testdata/TestRunPipe/wrapped-in-dir/wrapped-in-dir.installer.yaml.golden @@ -9,21 +9,21 @@ Installers: - Architecture: x64 NestedInstallerType: portable NestedInstallerFiles: - - RelativeFilePath: foo\foo.exe + - RelativeFilePath: foo\bin\foo.exe InstallerUrl: https://dummyhost/download/v1.2.1/foo_windows_amd64v1.zip InstallerSha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 UpgradeBehavior: uninstallPrevious - Architecture: x86 NestedInstallerType: portable NestedInstallerFiles: - - RelativeFilePath: foo\foo.exe + - RelativeFilePath: foo\bin\foo.exe InstallerUrl: https://dummyhost/download/v1.2.1/foo_windows_386.zip InstallerSha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 UpgradeBehavior: uninstallPrevious - Architecture: arm64 NestedInstallerType: portable NestedInstallerFiles: - - RelativeFilePath: foo\foo.exe + - RelativeFilePath: foo\bin\foo.exe InstallerUrl: https://dummyhost/download/v1.2.1/foo_windows_arm64.zip InstallerSha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 UpgradeBehavior: uninstallPrevious diff --git a/internal/pipe/winget/winget.go b/internal/pipe/winget/winget.go index 4c061c410..9e0a9628d 100644 --- a/internal/pipe/winget/winget.go +++ b/internal/pipe/winget/winget.go @@ -224,7 +224,7 @@ func (p Pipe) doRun(ctx *context.Context, winget config.Winget, cl client.Releas folder := artifact.ExtraOr(*archive, artifact.ExtraWrappedIn, ".") for _, bin := range artifact.ExtraOr(*archive, artifact.ExtraBinaries, []string{}) { files = append(files, InstallerItemFile{ - RelativeFilePath: windowsJoin([2]string{folder, bin}), + RelativeFilePath: strings.ReplaceAll(filepath.Join(folder, bin), "/", "\\"), }) } url, err := tmpl.New(ctx).WithArtifact(archive).Apply(winget.URLTemplate) @@ -397,10 +397,3 @@ func extFor(tp artifact.Type) string { return "" } } - -func windowsJoin(elem [2]string) string { - if elem[0] == "" { - return elem[1] - } - return elem[0] + "\\" + elem[1] -} diff --git a/internal/pipe/winget/winget_test.go b/internal/pipe/winget/winget_test.go index c7a23b7bf..9f7113463 100644 --- a/internal/pipe/winget/winget_test.go +++ b/internal/pipe/winget/winget_test.go @@ -602,15 +602,24 @@ func TestRunPipe(t *testing.T) { goarch := "amd64" createFakeArtifact("partial", goos, goarch, "v1", "", nil) createFakeArtifact("foo", goos, goarch, "v1", "", nil) - createFakeArtifact("wrapped-in-dir", goos, goarch, "v1", "", map[string]any{artifact.ExtraWrappedIn: "foo"}) + createFakeArtifact("wrapped-in-dir", goos, goarch, "v1", "", map[string]any{ + artifact.ExtraWrappedIn: "foo", + artifact.ExtraBinaries: []string{"bin/foo.exe"}, + }) goarch = "386" createFakeArtifact("foo", goos, goarch, "", "", nil) - createFakeArtifact("wrapped-in-dir", goos, goarch, "", "", map[string]any{artifact.ExtraWrappedIn: "foo"}) + createFakeArtifact("wrapped-in-dir", goos, goarch, "", "", map[string]any{ + artifact.ExtraWrappedIn: "foo", + artifact.ExtraBinaries: []string{"bin/foo.exe"}, + }) goarch = "arm64" createFakeArtifact("foo", goos, goarch, "", "", nil) - createFakeArtifact("wrapped-in-dir", goos, goarch, "", "", map[string]any{artifact.ExtraWrappedIn: "foo"}) + createFakeArtifact("wrapped-in-dir", goos, goarch, "", "", map[string]any{ + artifact.ExtraWrappedIn: "foo", + artifact.ExtraBinaries: []string{"bin/foo.exe"}, + }) client := client.NewMock() pipe := Pipe{}