Skip to content

Commit

Permalink
Better logging of failed commands' output
Browse files Browse the repository at this point in the history
  • Loading branch information
LoganDark committed May 9, 2024
1 parent ba8bfbe commit 6700424
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions crates/node_runtime/src/node_runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -483,14 +483,31 @@ impl NodeRuntime for RealNodeRuntime {

command.arg(subcommand);
command.args(args);
log::info!("{command:?}");
log::info!("executing command {command:?}");

match command.output().await.context("executing npm subprocess")? {
output if !output.status.success() => {
bail!("subprocess returned exit code {}", output.status)
log::error!(
"{} returned from command {:?}\nstdout: {:?}\nstderr: {:?}",
output.status,
command,
String::from_utf8_lossy(&output.stdout),
String::from_utf8_lossy(&output.stderr)
);

bail!("subprocess returned {}", output.status)
}

output => Ok(output),
output => {
log::info!(
"{} returned from command {:?}\nstderr: {:?}",
output.status,
command,
String::from_utf8_lossy(&output.stderr)
);

Ok(output)
}
}
};

Expand Down

0 comments on commit 6700424

Please sign in to comment.