Skip to content

Commit 3f59e09

Browse files
authored
fix: only print out debug info if cargo_warnings is true (#960)
1 parent e814ca5 commit 3f59e09

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/command_helpers.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,12 @@ fn write_warning(line: &[u8]) {
196196
stdout.write_all(b"\n").unwrap();
197197
}
198198

199-
fn wait_on_child(cmd: &Command, program: &str, child: &mut Child) -> Result<(), Error> {
199+
fn wait_on_child(
200+
cmd: &Command,
201+
program: &str,
202+
child: &mut Child,
203+
cargo_output: &CargoOutput,
204+
) -> Result<(), Error> {
200205
StderrForwarder::new(child).forward_all();
201206

202207
let status = match child.wait() {
@@ -211,7 +216,8 @@ fn wait_on_child(cmd: &Command, program: &str, child: &mut Child) -> Result<(),
211216
));
212217
}
213218
};
214-
println!("{}", status);
219+
220+
cargo_output.print_warning(&status);
215221

216222
if status.success() {
217223
Ok(())
@@ -280,7 +286,7 @@ pub(crate) fn run(
280286
cargo_output: &CargoOutput,
281287
) -> Result<(), Error> {
282288
let mut child = spawn(cmd, program, cargo_output)?;
283-
wait_on_child(cmd, program, &mut child)
289+
wait_on_child(cmd, program, &mut child, cargo_output)
284290
}
285291

286292
pub(crate) fn run_output(
@@ -300,7 +306,7 @@ pub(crate) fn run_output(
300306
.read_to_end(&mut stdout)
301307
.unwrap();
302308

303-
wait_on_child(cmd, program, &mut child)?;
309+
wait_on_child(cmd, program, &mut child, cargo_output)?;
304310

305311
Ok(stdout)
306312
}
@@ -320,7 +326,7 @@ pub(crate) fn spawn(
320326
}
321327
}
322328

323-
println!("running: {:?}", cmd);
329+
cargo_output.print_warning(&format_args!("running: {:?}", cmd));
324330

325331
let cmd = ResetStderr(cmd);
326332
let child = cmd.0.stderr(cargo_output.stdio_for_warnings()).spawn();

0 commit comments

Comments
 (0)