mirror of
https://github.com/crate-ci/typos.git
synced 2025-01-24 07:28:57 -05:00
fix(cli): Ensure we can run on files
This commit is contained in:
parent
6e8f7cf9d3
commit
60fe94c292
2 changed files with 12 additions and 4 deletions
|
@ -172,13 +172,14 @@ fn run_checks(
|
||||||
let mut errors_found = false;
|
let mut errors_found = false;
|
||||||
for path in args.path.iter() {
|
for path in args.path.iter() {
|
||||||
let cwd = if path == std::path::Path::new("-") {
|
let cwd = if path == std::path::Path::new("-") {
|
||||||
global_cwd.as_path()
|
global_cwd.clone()
|
||||||
} else if path.is_file() {
|
} else if path.is_file() {
|
||||||
path.parent().unwrap()
|
let mut cwd = path.canonicalize().with_code(proc_exit::Code::USAGE_ERR)?;
|
||||||
|
cwd.pop();
|
||||||
|
cwd
|
||||||
} else {
|
} else {
|
||||||
path.as_path()
|
path.clone()
|
||||||
};
|
};
|
||||||
let cwd = cwd.canonicalize().with_code(proc_exit::Code::USAGE_ERR)?;
|
|
||||||
|
|
||||||
engine
|
engine
|
||||||
.init_dir(&cwd)
|
.init_dir(&cwd)
|
||||||
|
|
|
@ -22,3 +22,10 @@ fn test_stdin_correct() {
|
||||||
.write_stdin("Apropriate world");
|
.write_stdin("Apropriate world");
|
||||||
cmd.assert().success().stdout("Appropriate world");
|
cmd.assert().success().stdout("Appropriate world");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_file_failure() {
|
||||||
|
let mut cmd = Command::cargo_bin("typos").unwrap();
|
||||||
|
cmd.arg("README.md");
|
||||||
|
cmd.assert().code(2);
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue