From 4026a71880f0da8a5fa49333e60f38f12588f004 Mon Sep 17 00:00:00 2001 From: Shunsuke Suzuki Date: Tue, 16 Jul 2024 15:59:43 +0900 Subject: [PATCH] fix: remove file extension .exe and .bat from command name on Windows (#537) --- pkg/cli/proxy.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkg/cli/proxy.go b/pkg/cli/proxy.go index 8b2edc5..06a8bce 100644 --- a/pkg/cli/proxy.go +++ b/pkg/cli/proxy.go @@ -8,6 +8,8 @@ import ( "os" "os/exec" "path/filepath" + "runtime" + "strings" "time" "github.com/suzuki-shunsuke/go-error-with-exit-code/ecerror" @@ -23,6 +25,13 @@ var errAquaCantBeExecuted = errors.New(`the command "aqua" can't be executed via func (runner *Runner) Run(ctx context.Context, args ...string) error { cmdName := filepath.Base(args[0]) + if runtime.GOOS == "windows" { + if e := strings.TrimSuffix(cmdName, ".exe"); e != cmdName { + cmdName = e + } else if e := strings.TrimSuffix(cmdName, ".bat"); e != cmdName { + cmdName = e + } + } if cmdName == "aqua" { fmt.Fprintln(os.Stderr, "[ERROR] "+errAquaCantBeExecuted.Error()) return errAquaCantBeExecuted