Run a command without producing any output in STDOUT and STDERR
(cmd: &str, args: &[&str])
| 20 | |
| 21 | /// Run a command without producing any output in STDOUT and STDERR |
| 22 | pub async fn silent_command(cmd: &str, args: &[&str]) -> Result<(), CommandError> { |
| 23 | let child = new_command(cmd) |
| 24 | .args(args) |
| 25 | .stdout(Stdio::piped()) |
| 26 | .stderr(Stdio::piped()) |
| 27 | .spawn(); |
| 28 | let Ok(mut child) = child else { |
| 29 | return Err(capture_error(cmd, args, None, Some(child.err().unwrap())).await); |
| 30 | }; |
| 31 | |
| 32 | let result = child.wait().await; |
| 33 | let Ok(result) = result else { |
| 34 | return Err(capture_error(cmd, args, Some(&mut child), None).await); |
| 35 | }; |
| 36 | |
| 37 | tracing::trace!(%result); |
| 38 | |
| 39 | if result.success() { |
| 40 | Ok(()) |
| 41 | } else { |
| 42 | Err(capture_error(cmd, args, Some(&mut child), None).await) |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | async fn capture_error( |
| 47 | cmd: &str, |
no test coverage detected