From 3bae999225ad493ea481309a2846b2a099d6eacd Mon Sep 17 00:00:00 2001 From: Ed Page Date: Wed, 9 Aug 2023 08:21:53 -0500 Subject: [PATCH] fix(cli): Report bad exit code on disallowed --- crates/typos-cli/src/bin/typos-cli/report.rs | 2 +- crates/typos-cli/src/report.rs | 4 ++-- crates/typos-cli/tests/cmd/config-disallowed.toml | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/crates/typos-cli/src/bin/typos-cli/report.rs b/crates/typos-cli/src/bin/typos-cli/report.rs index 3f86f51..8f3970a 100644 --- a/crates/typos-cli/src/bin/typos-cli/report.rs +++ b/crates/typos-cli/src/bin/typos-cli/report.rs @@ -89,7 +89,7 @@ impl<'r> MessageStatus<'r> { impl<'r> Report for MessageStatus<'r> { fn report(&self, msg: Message) -> Result<(), std::io::Error> { - if msg.is_correction() { + if msg.is_typo() { self.typos_found.store(true, atomic::Ordering::Relaxed); } if msg.is_error() { diff --git a/crates/typos-cli/src/report.rs b/crates/typos-cli/src/report.rs index e11ac52..06aee50 100644 --- a/crates/typos-cli/src/report.rs +++ b/crates/typos-cli/src/report.rs @@ -20,10 +20,10 @@ pub enum Message<'m> { } impl<'m> Message<'m> { - pub fn is_correction(&self) -> bool { + pub fn is_typo(&self) -> bool { match self { Message::BinaryFile(_) => false, - Message::Typo(c) => c.corrections.is_correction(), + Message::Typo(c) => !c.corrections.is_valid(), Message::FileType(_) => false, Message::File(_) => false, Message::Parse(_) => false, diff --git a/crates/typos-cli/tests/cmd/config-disallowed.toml b/crates/typos-cli/tests/cmd/config-disallowed.toml index e484ec5..3185611 100644 --- a/crates/typos-cli/tests/cmd/config-disallowed.toml +++ b/crates/typos-cli/tests/cmd/config-disallowed.toml @@ -1,4 +1,5 @@ bin.name = "typos" +status.code = 2 stdin = "" stdout = """ error: `hello` is disallowed