mirror of
https://github.com/crate-ci/typos.git
synced 2025-01-09 08:14:53 -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;
|
||||
for path in args.path.iter() {
|
||||
let cwd = if path == std::path::Path::new("-") {
|
||||
global_cwd.as_path()
|
||||
global_cwd.clone()
|
||||
} else if path.is_file() {
|
||||
path.parent().unwrap()
|
||||
let mut cwd = path.canonicalize().with_code(proc_exit::Code::USAGE_ERR)?;
|
||||
cwd.pop();
|
||||
cwd
|
||||
} else {
|
||||
path.as_path()
|
||||
path.clone()
|
||||
};
|
||||
let cwd = cwd.canonicalize().with_code(proc_exit::Code::USAGE_ERR)?;
|
||||
|
||||
engine
|
||||
.init_dir(&cwd)
|
||||
|
|
|
@ -22,3 +22,10 @@ fn test_stdin_correct() {
|
|||
.write_stdin("Apropriate 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…
Reference in a new issue