Skip to content

Commit

Permalink
fix(cli): 🐛 printed stdout and well as stderr if a stage fails
Browse files Browse the repository at this point in the history
It seems sometimes the CLI misses some errors otherwise. Note that this isn't yet confirmed to be the solution to #74.
  • Loading branch information
arctic-hen7 committed Nov 13, 2021
1 parent a3f879c commit ea1f1f1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion packages/perseus-cli/src/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@ pub fn run_cmd(
None => 1, // If we don't know an exit code but we know that the command failed, return 1 (general error code)
};

// Print `stderr` only if there's something therein and the exit code is non-zero
// Print `stderr` and `stdout` only if there's something therein and the exit code is non-zero
// If we only print `stderr`, we can miss some things (see #74)
if !output.stderr.is_empty() && exit_code != 0 {
pre_dump();
std::io::stderr().write_all(&output.stdout).unwrap();
std::io::stderr().write_all(&output.stderr).unwrap();
}

Expand Down
3 changes: 2 additions & 1 deletion packages/perseus-cli/src/serve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,10 @@ fn run_server(
None if output.status.success() => 0, // If we don't, but we know the command succeeded, return 0 (success code)
None => 1, // If we don't know an exit code but we know that the command failed, return 1 (general error code)
};
// Print `stderr` only if there's something therein and the exit code is non-zero
// Print `stderr` and stdout` only if there's something therein and the exit code is non-zero
if !output.stderr.is_empty() && exit_code != 0 {
// We don't print any failure message other than the actual error right now (see if people want something else?)
std::io::stderr().write_all(&output.stdout).unwrap();
std::io::stderr().write_all(&output.stderr).unwrap();
return Ok(1);
}
Expand Down

0 comments on commit ea1f1f1

Please sign in to comment.