(ctx context.Context, dir, cmd string, args, env []string)
| 25 | } |
| 26 | |
| 27 | func ExecWithContextInDir(ctx context.Context, dir, cmd string, args, env []string) (CmdResult, error) { |
| 28 | command := exec.CommandContext(ctx, cmd, args...) |
| 29 | command.Dir = dir |
| 30 | command.Env = append(os.Environ(), env...) |
| 31 | res, err := runCmd(command) |
| 32 | if err != nil { |
| 33 | return res, fmt.Errorf("executing '%s %s' : %s: %s", cmd, strings.Join(args, " "), err.Error(), res.Stdout+"\n"+res.Stderr) |
| 34 | } |
| 35 | return res, nil |
| 36 | } |
| 37 | |
| 38 | func runCmd(c *exec.Cmd) (CmdResult, error) { |
| 39 | if c.Stdout != nil { |
no test coverage detected