Skip to content

Commit

Permalink
fix(cli): Report more errors through report system
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Aug 18, 2023
1 parent 104ebdc commit c927717
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions crates/typos-cli/src/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -696,10 +696,15 @@ fn walk_entry(
let explicit = entry.depth() == 0;
let (path, lookup_path) = if entry.is_stdin() {
let path = std::path::Path::new("-");
(path, std::env::current_dir()?)
let cwd = std::env::current_dir().map_err(|err| {
let kind = err.kind();
std::io::Error::new(kind, "no current working directory".to_owned())
})?;
(path, cwd)
} else {
let path = entry.path();
(path, path.canonicalize()?)
let abs_path = report_result(path.canonicalize(), Some(path), reporter)?;
(path, abs_path)
};
let policy = engine.policy(&lookup_path);
checks.check_file(path, explicit, &policy, reporter)?;
Expand Down

0 comments on commit c927717

Please sign in to comment.