feat: make part of summary red if errors exist

This commit is contained in:
rvcas 2023-01-16 15:14:46 -05:00 committed by Lucas
parent 4024add4da
commit 38734361d0
1 changed files with 17 additions and 9 deletions

View File

@ -32,21 +32,29 @@ where
warning.report() warning.report()
} }
let plural = if warning_count == 1 { "" } else { "s" };
if let Err(err) = build_result { if let Err(err) = build_result {
err.report(); err.report();
println!("\n{}", "Summary".purple().bold()); println!("\n{}", "Summary".purple().bold());
println!(
" {} error(s), {}", let warning_text = format!("{warning_count} warning{}", plural);
err.len(),
format!("{warning_count} warning(s)").yellow(), let plural = if err.len() == 1 { "" } else { "s" };
);
let error_text = format!("{} error{}", err.len(), plural);
let full_summary = format!(" {}, {}", error_text.red(), warning_text.yellow());
println!("{}", full_summary);
process::exit(1); process::exit(1);
} else { } else {
println!("\n{}", "Summary".purple().bold()); println!("\n{}", "Summary".purple().bold());
println!(
" 0 error, {}", let warning_text = format!("{warning_count} warning{}", plural);
format!("{warning_count} warning(s)").yellow(),
); println!(" 0 errors, {}", warning_text.yellow(),);
} }
Ok(()) Ok(())
} }