diff --git a/cmd/node.go b/cmd/node.go index dc2d099..32bc6f2 100644 --- a/cmd/node.go +++ b/cmd/node.go @@ -9,9 +9,13 @@ import ( var NodeNotFound = errors.New("nodejs not found") -func Node(args ...string) (output string, err error) { +func Node(options BasicOptions, args ...string) (output string, err error) { - if _, err := Which("node"); err != nil { + if _, err := Which("node", BasicOptions{ + Env: options.Env, + Sources: options.Sources, + Cwd: options.Cwd, + }); err != nil { if errors.Is(err, ErrNotFound) { return "", NodeNotFound } else { diff --git a/cmd/pip.go b/cmd/pip.go index 1dd3a01..974b3ee 100644 --- a/cmd/pip.go +++ b/cmd/pip.go @@ -7,9 +7,13 @@ import ( "strings" ) -func Pip(args ...string) (output string, err error) { +func Pip(options BasicOptions, args ...string) (output string, err error) { - if _, err := Which("python3"); err != nil { + if _, err := Which("python3", BasicOptions{ + Env: options.Env, + Sources: options.Sources, + Cwd: options.Cwd, + }); err != nil { if errors.Is(err, ErrNotFound) { return "", PythonNotFound } else { diff --git a/cmd/python.go b/cmd/python.go index 9592a67..2945854 100644 --- a/cmd/python.go +++ b/cmd/python.go @@ -9,9 +9,13 @@ import ( var PythonNotFound = errors.New("python not found") -func Python(args ...string) (output string, err error) { +func Python(options BasicOptions, args ...string) (output string, err error) { - if _, err := Which("python3"); err != nil { + if _, err := Which("python3", BasicOptions{ + Env: options.Env, + Sources: options.Sources, + Cwd: options.Cwd, + }); err != nil { if errors.Is(err, ErrNotFound) { return "", PythonNotFound } else { diff --git a/cmd/which.go b/cmd/which.go index 647d809..80b5fae 100644 --- a/cmd/which.go +++ b/cmd/which.go @@ -9,13 +9,13 @@ import ( var ErrNotFound = errors.New("which: command not found") -type WhichOptions struct { +type BasicOptions struct { Env map[string]string Sources []string Cwd string } -func Which(cmd string, options WhichOptions) (dir string, err error) { +func Which(cmd string, options BasicOptions) (dir string, err error) { var sourceCommand strings.Builder for _, value := range options.Sources { diff --git a/linux/utils.go b/linux/utils.go index db2a126..2f18318 100644 --- a/linux/utils.go +++ b/linux/utils.go @@ -12,7 +12,7 @@ import ( func (cmd *LinuxCommand) isCommandExecutable(command string) (bool, error) { - whichOut, err := cmd2.Which(command, cmd2.WhichOptions{ + whichOut, err := cmd2.Which(command, cmd2.BasicOptions{ Env: cmd.Options.Env, Sources: cmd.Options.Sources, Cwd: cmd.Options.Cwd,