Skip to content

Commit

Permalink
fix: wait for command to complete
Browse files Browse the repository at this point in the history
without wait(), the *ProcessState is nil, meaning we can't access
the ExitCode(). On Windows, calling wait() introduces a timeout
which makes things run slower, which is why we only call wait()
in case of an error. That should not be the main use-case.

relates to #285
  • Loading branch information
JanDeDobbeleer committed Dec 31, 2020
1 parent 7e74835 commit d9d2430
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@ func (env *environment) runCommand(command string, args ...string) (string, erro
stdoutString := getOutputString(stdout)
stderrString := getOutputString(stderr)
if stderrString != "" {
// only wait in case of error reduces the lead time on successful
// commands on windows due to not calling process.Wait()
_ = cmd.Wait()
return "", &commandError{
err: stderrString,
exitCode: cmd.ProcessState.ExitCode(),
Expand Down

0 comments on commit d9d2430

Please sign in to comment.