Run executes name with args. If name is empty, it falls back to shell mode using the first arg as the full command.
(name string, args []string, stdout, stderr io.Writer)
| 33 | // Run executes name with args. If name is empty, it falls back to shell mode |
| 34 | // using the first arg as the full command. |
| 35 | func (ShellRunner) Run(name string, args []string, stdout, stderr io.Writer) (int, error) { |
| 36 | if name == "" { |
| 37 | return 1, errors.New("tools: empty command") |
| 38 | } |
| 39 | cmd := exec.Command(name, args...) |
| 40 | cmd.Stdin = os.Stdin |
| 41 | cmd.Stdout = stdout |
| 42 | cmd.Stderr = stderr |
| 43 | if err := cmd.Run(); err != nil { |
| 44 | var exitErr *exec.ExitError |
| 45 | if errors.As(err, &exitErr) { |
| 46 | return exitErr.ExitCode(), nil |
| 47 | } |
| 48 | return 1, err |
| 49 | } |
| 50 | return 0, nil |
| 51 | } |
| 52 | |
| 53 | // Install runs the install_cmd for the given tool, streaming output through w. |
| 54 | // Empty install_cmd returns nil with a "no install command" sentinel. |