X Tutup
Skip to content

Commit 42ce8fa

Browse files
author
nate smith
committed
dispatch binary extensions directly
1 parent d84a7c7 commit 42ce8fa

File tree

4 files changed

+47
-2
lines changed

4 files changed

+47
-2
lines changed

pkg/cmd/extension/extension.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,7 @@ func (e *Extension) UpdateAvailable() bool {
4848
}
4949
return true
5050
}
51+
52+
func (e *Extension) IsBinary() bool {
53+
return e.kind == BinaryKind
54+
}

pkg/cmd/extension/manager.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,11 @@ func (m *Manager) Dispatch(args []string, stdin io.Reader, stdout, stderr io.Wri
6969
forwardArgs := args[1:]
7070

7171
exts, _ := m.list(false)
72+
var ext Extension
7273
for _, e := range exts {
7374
if e.Name() == extName {
74-
exe = e.Path()
75+
ext = e
76+
exe = ext.Path()
7577
break
7678
}
7779
}
@@ -81,7 +83,9 @@ func (m *Manager) Dispatch(args []string, stdin io.Reader, stdout, stderr io.Wri
8183

8284
var externalCmd *exec.Cmd
8385

84-
if runtime.GOOS == "windows" {
86+
if ext.IsBinary() {
87+
externalCmd = m.newCommand(exe, forwardArgs...)
88+
} else if runtime.GOOS == "windows" {
8589
// Dispatch all extension calls through the `sh` interpreter to support executable files with a
8690
// shebang line on Windows.
8791
shExe, err := m.findSh()

pkg/extensions/extension.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ type Extension interface {
1313
URL() string
1414
IsLocal() bool
1515
UpdateAvailable() bool
16+
IsBinary() bool
1617
}
1718

1819
//go:generate moq -rm -out manager_mock.go . ExtensionManager

pkg/extensions/extension_mock.go

Lines changed: 36 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
X Tutup