Skip to content

Commit 67d65d0

Browse files
committed
tidy: run typos check in src root, not current dir
1 parent 0935bc8 commit 67d65d0

File tree

1 file changed

+17
-4
lines changed
  • src/tools/tidy/src/extra_checks

1 file changed

+17
-4
lines changed

src/tools/tidy/src/extra_checks/mod.rs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ fn check_impl(
295295
} else {
296296
eprintln!("spellcheck files");
297297
}
298-
spellcheck_runner(&outdir, &cargo, &args)?;
298+
spellcheck_runner(root_path, &outdir, &cargo, &args)?;
299299
}
300300

301301
if js_lint || js_typecheck {
@@ -579,12 +579,25 @@ fn shellcheck_runner(args: &[&OsStr]) -> Result<(), Error> {
579579
}
580580

581581
/// Ensure that spellchecker is installed then run it at the given path
582-
fn spellcheck_runner(outdir: &Path, cargo: &Path, args: &[&str]) -> Result<(), Error> {
582+
fn spellcheck_runner(
583+
src_root: &Path,
584+
outdir: &Path,
585+
cargo: &Path,
586+
args: &[&str],
587+
) -> Result<(), Error> {
583588
let bin_path =
584589
crate::ensure_version_or_cargo_install(outdir, cargo, "typos-cli", "typos", "1.34.0")?;
585590

586-
let status = Command::new(bin_path).args(args).status()?;
587-
if status.success() { Ok(()) } else { Err(Error::FailedCheck("typos")) }
591+
match Command::new(bin_path).current_dir(src_root).args(args).status() {
592+
Ok(status) => {
593+
if status.success() {
594+
Ok(())
595+
} else {
596+
Err(Error::FailedCheck("typos"))
597+
}
598+
}
599+
Err(err) => Err(Error::Generic(format!("failed to run typos tool: {err:?}"))),
600+
}
588601
}
589602

590603
/// Check git for tracked files matching an extension

0 commit comments

Comments
 (0)