Skip to content

Commit

Permalink
fix: remove file extension .exe and .bat from command name on Windows (
Browse files Browse the repository at this point in the history
  • Loading branch information
suzuki-shunsuke authored Jul 16, 2024
1 parent 005832a commit 4026a71
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pkg/cli/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"os"
"os/exec"
"path/filepath"
"runtime"
"strings"
"time"

"github.com/suzuki-shunsuke/go-error-with-exit-code/ecerror"
Expand All @@ -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
Expand Down

0 comments on commit 4026a71

Please sign in to comment.