dev_scripts/
cmd.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use std::process::Output;

use anyhow::{bail, Result};

/// Make sure a command finished successfully, otherwise throw an error.
pub fn ensure_success(output: &Output) -> Result<()> {
    let stderr = String::from_utf8_lossy(&output.stderr);
    let stdout = String::from_utf8_lossy(&output.stdout);

    if !output.status.success() {
        bail!("Failed to run command:\nstdout:\n{stdout}\nstderr:\n{stderr}");
    }

    Ok(())
}