Skip to content

Commit

Permalink
Better format for multi-line stderr output in localcmd
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Nephin <[email protected]>
  • Loading branch information
dnephin committed Dec 9, 2023
1 parent 0a2919f commit e71dbf9
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions internal/tiltfile/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,13 @@ func (s *tiltfileState) execLocalCmd(t *starlark.Thread, cmd model.Cmd, options
if !options.logOutput {
// if we already logged the output, don't include it in the error message to prevent it from
// getting output 2x
errMessage.WriteString(fmt.Sprintf("\nstdout: %q\nstderr: %q",
stdoutBuf.String(), stderrBuf.String()))

stdout, stderr := stdoutBuf.String(), stderrBuf.String()
if strings.Contains(stdout, "\n") || strings.Contains(stderr, "\n") {
fmt.Fprintf(&errMessage, "\nstdout:\n%v\nstderr:\n%v\n", stdout, stderr)
} else {
fmt.Fprintf(&errMessage, "\nstdout: %q\nstderr: %q\n", stdout, stderr)
}
}

return "", errors.New(errMessage.String())
Expand Down

0 comments on commit e71dbf9

Please sign in to comment.