update which options
This commit is contained in:
parent
5d646427bd
commit
991429a290
5 changed files with 21 additions and 9 deletions
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue