mirror of
https://github.com/Noratrieb/website.git
synced 2026-01-14 17:05:02 +01:00
Submodules
This commit is contained in:
commit
43d792e148
10 changed files with 712 additions and 0 deletions
21
src/utils.rs
Normal file
21
src/utils.rs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
use color_eyre::{
|
||||
eyre::{bail, Context},
|
||||
Result,
|
||||
};
|
||||
use std::process::Command;
|
||||
|
||||
pub fn run_process(cmd: &mut Command) -> Result<String> {
|
||||
let name = cmd.get_program().to_os_string();
|
||||
let output = cmd
|
||||
.output()
|
||||
.wrap_err(format!("failed to spawn process {name:?}"))?;
|
||||
|
||||
if !output.status.success() {
|
||||
bail!(
|
||||
"command returned error: {}",
|
||||
String::from_utf8(output.stderr).wrap_err("stderr is not UTF-8")?
|
||||
);
|
||||
}
|
||||
|
||||
Ok(String::from_utf8(output.stdout).wrap_err("stdout is not UTF-8")?)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue