Print stderr too and only output when warn/error conditions happen.
This commit is contained in:
parent
7338b5667a
commit
c4c45a0368
|
@ -38,7 +38,10 @@ pub fn hooked_run(config: Config, hook_type: String) -> Result<()> {
|
||||||
)),
|
)),
|
||||||
}?;
|
}?;
|
||||||
|
|
||||||
let mut process = command.stdout(Redirection::Pipe).popen()?;
|
let mut process = command
|
||||||
|
.stderr(Redirection::Merge)
|
||||||
|
.stdout(Redirection::Pipe)
|
||||||
|
.popen()?;
|
||||||
let exit_status = process.wait()?;
|
let exit_status = process.wait()?;
|
||||||
let output = {
|
let output = {
|
||||||
let mut output = String::new();
|
let mut output = String::new();
|
||||||
|
@ -47,15 +50,17 @@ pub fn hooked_run(config: Config, hook_type: String) -> Result<()> {
|
||||||
output
|
output
|
||||||
};
|
};
|
||||||
|
|
||||||
let (stop, prefix, style) = match (exit_status.success(), hook.on_failure)
|
let (stop, print_output, prefix, style) =
|
||||||
{
|
match (exit_status.success(), hook.on_failure) {
|
||||||
(true, _) => (false, "✓", success_style),
|
(true, _) => (false, false, "✓", success_style),
|
||||||
(false, ExitAction::Continue) => (false, "⚠", warn_style),
|
(false, ExitAction::Continue) => (false, true, "⚠", warn_style),
|
||||||
(false, ExitAction::Stop) => (true, "✗", error_style),
|
(false, ExitAction::Stop) => (true, true, "✗", error_style),
|
||||||
};
|
};
|
||||||
|
|
||||||
println!("\t{} {}", prefix.style(style), hook_name.style(style));
|
println!("\t{} {}", prefix.style(style), hook_name.style(style));
|
||||||
|
if !output.is_empty() && print_output {
|
||||||
println!("{}", output);
|
println!("{}", output);
|
||||||
|
}
|
||||||
|
|
||||||
if stop {
|
if stop {
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
Loading…
Reference in New Issue