Skip to content

Commit 86a806f

Browse files
committed
fix: only print out debug info if cargo_warnings is true
1 parent e814ca5 commit 86a806f

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

src/command_helpers.rs

Lines changed: 15 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,10 @@ fn wait_on_child(cmd: &Command, program: &str, child: &mut Child) -> Result<(),
211216
));
212217
}
213218
};
214-
println!("{}", status);
219+
220+
if cargo_output.warnings {
221+
println!("{}", status);
222+
}
215223

216224
if status.success() {
217225
Ok(())
@@ -280,7 +288,7 @@ pub(crate) fn run(
280288
cargo_output: &CargoOutput,
281289
) -> Result<(), Error> {
282290
let mut child = spawn(cmd, program, cargo_output)?;
283-
wait_on_child(cmd, program, &mut child)
291+
wait_on_child(cmd, program, &mut child, cargo_output)
284292
}
285293

286294
pub(crate) fn run_output(
@@ -300,7 +308,7 @@ pub(crate) fn run_output(
300308
.read_to_end(&mut stdout)
301309
.unwrap();
302310

303-
wait_on_child(cmd, program, &mut child)?;
311+
wait_on_child(cmd, program, &mut child, cargo_output)?;
304312

305313
Ok(stdout)
306314
}
@@ -320,7 +328,9 @@ pub(crate) fn spawn(
320328
}
321329
}
322330

323-
println!("running: {:?}", cmd);
331+
if cargo_output.warnings {
332+
println!("running: {:?}", cmd);
333+
}
324334

325335
let cmd = ResetStderr(cmd);
326336
let child = cmd.0.stderr(cargo_output.stdio_for_warnings()).spawn();

0 commit comments

Comments
 (0)