diff --git a/src/main.rs b/src/main.rs index fd2bca4..88f6116 100755 --- a/src/main.rs +++ b/src/main.rs @@ -351,6 +351,8 @@ fn process_lint_command( }; let is_multiple_files = files.len() > 1; + let mut has_errors = false; + for file_path in files { if let Err(e) = process_single_file_lint( &file_path, @@ -364,12 +366,18 @@ fn process_lint_command( is_multiple_files, ) { eprintln!("Error processing {}: {}", file_path, e); + has_errors = true; if !is_multiple_files { return Err(e); } } } + // Exit with non-zero code if any file had errors + if has_errors { + std::process::exit(1); + } + Ok(()) } @@ -459,9 +467,9 @@ fn process_single_file_lint( println!("{}", diagnostics.to_human_readable()); } - // Exit with non-zero code if there are errors + // Return error if there are diagnostics errors if diagnostics.has_errors() { - std::process::exit(1); + return Err(anyhow::anyhow!("Diagnostics found errors in file")); } Ok(())