Skip to content

Commit b1e1370

Browse files
authored
Add new fn spawn_and_wait_for_output
1 parent b889445 commit b1e1370

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/command_helpers.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use std::{
99
hash::Hasher,
1010
io::{self, Read, Write},
1111
path::Path,
12-
process::{Child, ChildStderr, Command, Stdio},
12+
process::{Child, ChildStderr, Command, Output, Stdio},
1313
sync::{
1414
atomic::{AtomicBool, Ordering},
1515
Arc,
@@ -348,20 +348,20 @@ pub(crate) fn run(cmd: &mut Command, cargo_output: &CargoOutput) -> Result<(), E
348348
wait_on_child(cmd, &mut child, cargo_output)
349349
}
350350

351-
pub(crate) fn run_output(cmd: &mut Command, cargo_output: &CargoOutput) -> Result<Vec<u8>, Error> {
351+
pub(crate) fn spawn_and_wait_for_output(cmd: &mut Command, cargo_output: &CargoOutput) -> Result<Output, Error> {
352352
// We specifically need the output to be captured, so override default
353353
let mut captured_cargo_output = cargo_output.clone();
354354
captured_cargo_output.output = OutputKind::Capture;
355-
let Output {
356-
status,
357-
stdout,
358-
stderr,
359-
} = spawn(cmd, &captured_cargo_output)?
355+
spawn(cmd, &captured_cargo_output)?
360356
.wait_with_output()
361357
.map_err(|e| Err(Error::new(
362358
ErrorKind::ToolExecError,
363359
format!("failed to wait on spawned child process `{cmd:?}`: {e}"),
364-
)))?;
360+
)))
361+
}
362+
363+
pub(crate) fn run_output(cmd: &mut Command, cargo_output: &CargoOutput) -> Result<Vec<u8>, Error> {
364+
let Output { status, stdout, stderr } = spawn_and_wait_for_output(cmd, cargo_output)?;
365365

366366
stderr.split(|&b| b == b'\n').for_each(write_warning);
367367

0 commit comments

Comments
 (0)