Skip to content

Commit

Permalink
fix: return buffered stderr only when there are available bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
spatocode committed Sep 22, 2023
1 parent 7b7b5ab commit 798133c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions internal/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func GetShellCommandOutput(command string, args ...string) (string, error) {
var stderr bytes.Buffer
cmd.Stderr = &stderr
out, err := cmd.Output()
if err != nil {
if err != nil && stderr.Available() != 0 {
return string(out), errors.New(stderr.String())
}
return string(out), err
Expand All @@ -56,7 +56,7 @@ func GetShellCommandOutputWithEnv(env []string, command string, args ...string)
var stderr bytes.Buffer
cmd.Stderr = &stderr
out, err := cmd.Output()
if err != nil {
if err != nil && stderr.Available() != 0 {
return string(out), errors.New(stderr.String())
}
return string(out), err
Expand Down

0 comments on commit 798133c

Please sign in to comment.