Skip to content

Commit

Permalink
internal: Include stdout in command failures.
Browse files Browse the repository at this point in the history
  • Loading branch information
milesj committed Dec 6, 2023
1 parent 2690928 commit 9dd0239
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
4 changes: 2 additions & 2 deletions crates/pdk-api/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ impl InstallGlobalOutput {

Self {
installed: false,
error: Some(result.stderr),
error: Some(result.get_output()),
}
}
}
Expand Down Expand Up @@ -516,7 +516,7 @@ impl UninstallGlobalOutput {

Self {
uninstalled: false,
error: Some(result.stderr),
error: Some(result.get_output()),
}
}
}
Expand Down
17 changes: 17 additions & 0 deletions crates/pdk-api/src/host_funcs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,20 @@ json_struct!(
pub stdout: String,
}
);

impl ExecCommandOutput {
pub fn get_output(&self) -> String {
let mut out = String::new();
out.push_str(self.stdout.trim());

if !self.stderr.is_empty() {
if !out.is_empty() {
out.push(' ');
}

out.push_str(self.stderr.trim());
}

out
}
}

0 comments on commit 9dd0239

Please sign in to comment.