Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
rkrasiuk authored Sep 28, 2022
1 parent cea208c commit 39bb5b2
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions cli/src/cmd/forge/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,22 +91,27 @@ impl Cmd for FmtArgs {

// collect ignore paths first
let mut ignored = vec![];
for res in config.fmt.ignore.iter().map(|pattern| glob::glob(pattern)) {
let expanded = config
.fmt
.ignore
.iter()
.map(|pattern| glob::glob(&config.__root.0.join(pattern).display().to_string()));
for res in expanded {
match res {
Ok(paths) => ignored.extend(paths.into_iter().collect::<Result<Vec<_>, _>>()?),
Err(err) => {
eyre::bail!("failed to parse ignore glob pattern: {err}")
}
}
}
let ignored: Vec<_> = ignored.into_iter().map(|path| config.__root.0.join(path)).collect();

let cwd = std::env::current_dir()?;
let mut inputs = vec![];
for input in self.inputs(&config) {
match input {
Input::Path(p) => {
if (p.starts_with(&config.__root.0) && !ignored.contains(&p)) ||
!ignored.contains(&config.__root.0.join(&p))
if (p.is_absolute() && !ignored.contains(&p)) ||
!ignored.contains(&cwd.join(&p))
{
inputs.push(Input::Path(p));
}
Expand Down Expand Up @@ -241,6 +246,7 @@ impl Cmd for FmtArgs {

struct Line(Option<usize>);

#[derive(Debug)]
enum Input {
Path(PathBuf),
Stdin(String),
Expand Down

0 comments on commit 39bb5b2

Please sign in to comment.