Skip to content

Commit

Permalink
fix: only print out debug info if cargo_warnings is true (#960)
Browse files Browse the repository at this point in the history
  • Loading branch information
amaanq authored Feb 22, 2024
1 parent e814ca5 commit 3f59e09
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/command_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,12 @@ fn write_warning(line: &[u8]) {
stdout.write_all(b"\n").unwrap();
}

fn wait_on_child(cmd: &Command, program: &str, child: &mut Child) -> Result<(), Error> {
fn wait_on_child(
cmd: &Command,
program: &str,
child: &mut Child,
cargo_output: &CargoOutput,
) -> Result<(), Error> {
StderrForwarder::new(child).forward_all();

let status = match child.wait() {
Expand All @@ -211,7 +216,8 @@ fn wait_on_child(cmd: &Command, program: &str, child: &mut Child) -> Result<(),
));
}
};
println!("{}", status);

cargo_output.print_warning(&status);

if status.success() {
Ok(())
Expand Down Expand Up @@ -280,7 +286,7 @@ pub(crate) fn run(
cargo_output: &CargoOutput,
) -> Result<(), Error> {
let mut child = spawn(cmd, program, cargo_output)?;
wait_on_child(cmd, program, &mut child)
wait_on_child(cmd, program, &mut child, cargo_output)
}

pub(crate) fn run_output(
Expand All @@ -300,7 +306,7 @@ pub(crate) fn run_output(
.read_to_end(&mut stdout)
.unwrap();

wait_on_child(cmd, program, &mut child)?;
wait_on_child(cmd, program, &mut child, cargo_output)?;

Ok(stdout)
}
Expand All @@ -320,7 +326,7 @@ pub(crate) fn spawn(
}
}

println!("running: {:?}", cmd);
cargo_output.print_warning(&format_args!("running: {:?}", cmd));

let cmd = ResetStderr(cmd);
let child = cmd.0.stderr(cargo_output.stdio_for_warnings()).spawn();
Expand Down

0 comments on commit 3f59e09

Please sign in to comment.