From 36e53174609c2a4bd3042af3b3d0f39bdedfd130 Mon Sep 17 00:00:00 2001 From: Sasial <44125644+sasial-dev@users.noreply.github.com> Date: Sat, 6 Jan 2024 12:03:38 +1000 Subject: [PATCH] Zap should emit an exit code of 1 if any errors were thrown (#55) --- cli/src/main.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cli/src/main.rs b/cli/src/main.rs index 796c6bb7..bb31e417 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -3,6 +3,7 @@ use std::path::PathBuf; use anyhow::Result; use clap::Parser; use codespan_reporting::{ + diagnostic::Severity, files::SimpleFile, term::{ self, @@ -75,8 +76,12 @@ fn main() -> Result<()> { let writer = StandardStream::stderr(ColorChoice::Auto); let config_term = codespan_reporting::term::Config::default(); - for diagnostic in diagnostics { - term::emit(&mut writer.lock(), &config_term, &file, &diagnostic)?; + for diagnostic in &diagnostics { + term::emit(&mut writer.lock(), &config_term, &file, diagnostic)?; + } + + if diagnostics.iter().any(|diag| diag.severity == Severity::Error) { + std::process::exit(1) } Ok(())