Skip to content

Commit 627fbe4

Browse files
committed
ensure that required version of typos is installed if spellcheck invoked
1 parent 0c8c934 commit 627fbe4

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/tools/tidy/src/ext_tool_checks.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -516,8 +516,19 @@ fn shellcheck_runner(args: &[&OsStr]) -> Result<(), Error> {
516516

517517
/// Check that spellchecker is installed then run it at the given path
518518
fn spellcheck_runner(args: &[&str]) -> Result<(), Error> {
519-
match Command::new("typos").arg("--version").status() {
520-
Ok(_) => (),
519+
// sync version with .github/workflows/spellcheck.yml
520+
let expected_version = "typos-cli 1.34.0";
521+
match Command::new("typos").arg("--version").output() {
522+
Ok(o) => {
523+
let stdout = String::from_utf8_lossy(&o.stdout);
524+
if stdout.trim() != expected_version {
525+
return Err(Error::Version {
526+
program: "typos",
527+
required: expected_version,
528+
installed: stdout.trim().to_string(),
529+
});
530+
}
531+
}
521532
Err(e) if e.kind() == io::ErrorKind::NotFound => {
522533
return Err(Error::MissingReq(
523534
"typos",

0 commit comments

Comments
 (0)