Skip to content

Commit ea1f1f1

Browse files
committed
fix(cli): 🐛 printed stdout and well as stderr if a stage fails
It seems sometimes the CLI misses some errors otherwise. Note that this isn't yet confirmed to be the solution to #74.
1 parent a3f879c commit ea1f1f1

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

packages/perseus-cli/src/cmd.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,11 @@ pub fn run_cmd(
3939
None => 1, // If we don't know an exit code but we know that the command failed, return 1 (general error code)
4040
};
4141

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

packages/perseus-cli/src/serve.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,10 @@ fn run_server(
165165
None if output.status.success() => 0, // If we don't, but we know the command succeeded, return 0 (success code)
166166
None => 1, // If we don't know an exit code but we know that the command failed, return 1 (general error code)
167167
};
168-
// Print `stderr` only if there's something therein and the exit code is non-zero
168+
// Print `stderr` and stdout` only if there's something therein and the exit code is non-zero
169169
if !output.stderr.is_empty() && exit_code != 0 {
170170
// We don't print any failure message other than the actual error right now (see if people want something else?)
171+
std::io::stderr().write_all(&output.stdout).unwrap();
171172
std::io::stderr().write_all(&output.stderr).unwrap();
172173
return Ok(1);
173174
}

0 commit comments

Comments
 (0)