Skip to content

Commit

Permalink
xplatform test fix
Browse files Browse the repository at this point in the history
  • Loading branch information
nate smith committed Nov 12, 2021
1 parent 6b7889b commit 59d651b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
19 changes: 10 additions & 9 deletions pkg/cmd/extension/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type Manager struct {
lookPath func(string) (string, error)
findSh func() (string, error)
newCommand func(string, ...string) *exec.Cmd
platform func() string
platform func() (string, string)
client *http.Client
config config.Config
io *iostreams.IOStreams
Expand All @@ -44,8 +44,12 @@ func NewManager(io *iostreams.IOStreams) *Manager {
lookPath: safeexec.LookPath,
findSh: findsh.Find,
newCommand: exec.Command,
platform: func() string {
return fmt.Sprintf("%s-%s", runtime.GOOS, runtime.GOARCH)
platform: func() (string, string) {
ext := ""
if runtime.GOOS == "windows" {
ext = ".exe"
}
return fmt.Sprintf("%s-%s", runtime.GOOS, runtime.GOARCH), ext
},
io: io,
}
Expand Down Expand Up @@ -344,13 +348,10 @@ func (m *Manager) installBin(repo ghrepo.Interface) error {
return err
}

suffix := m.platform()
if runtime.GOOS == "windows" {
suffix += ".exe"
}
platform, ext := m.platform()
var asset *releaseAsset
for _, a := range r.Assets {
if strings.HasSuffix(a.Name, suffix) {
if strings.HasSuffix(a.Name, platform+ext) {
asset = &a
break
}
Expand All @@ -359,7 +360,7 @@ func (m *Manager) installBin(repo ghrepo.Interface) error {
if asset == nil {
return fmt.Errorf(
"%[1]s unsupported for %[2]s. Open an issue: `gh issue create -R %[3]s/%[1]s -t'Support %[2]s'`",
repo.RepoName(), m.platform(), repo.RepoOwner())
repo.RepoName(), platform, repo.RepoOwner())
}

name := repo.RepoName()
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/extension/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ func newTestManager(dir string, client *http.Client, io *iostreams.IOStreams) *M
config: config.NewBlankConfig(),
io: io,
client: client,
platform: func() string {
return "windows-amd64"
platform: func() (string, string) {
return "windows-amd64", ".exe"
},
}
}
Expand Down

0 comments on commit 59d651b

Please sign in to comment.