Skip to content

Commit

Permalink
Zap should emit an exit code of 1 if any errors were thrown (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
sasial-dev authored Jan 6, 2024
1 parent 43ce8ca commit 36e5317
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::path::PathBuf;
use anyhow::Result;
use clap::Parser;
use codespan_reporting::{
diagnostic::Severity,
files::SimpleFile,
term::{
self,
Expand Down Expand Up @@ -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(())
Expand Down

0 comments on commit 36e5317

Please sign in to comment.