Skip to content

Commit

Permalink
build: make run_command() return Err on verbose mode non-0 exit code
Browse files Browse the repository at this point in the history
  • Loading branch information
nick1udwig committed Aug 9, 2024
1 parent 51a5f8a commit 8c9d52d
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/build/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,19 @@ fn is_only_empty_string(splitted: &Vec<&str>) -> bool {
pub fn run_command(cmd: &mut Command, verbose: bool) -> Result<Option<(String, String)>> {
if verbose {
let mut child = cmd.spawn()?;
child.wait()?;
return Ok(None);
let result = child.wait()?;
if result.success() {
return Ok(None);
} else {
return Err(eyre!(
"Command `{} {:?}` failed with exit code {:?}",
cmd.get_program().to_str().unwrap(),
cmd.get_args()
.map(|a| a.to_str().unwrap())
.collect::<Vec<_>>(),
result.code(),
));
}
}
let output = cmd.output()?;
if output.status.success() {
Expand Down

0 comments on commit 8c9d52d

Please sign in to comment.