Skip to content

Commit

Permalink
chore(core): use globset to filter entries
Browse files Browse the repository at this point in the history
  • Loading branch information
Cammisuli committed Jun 27, 2023
1 parent ad6b243 commit c6fccb8
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/nx/src/native/walker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,19 @@ where
P: AsRef<Path> + 'a,
{
let base_dir: PathBuf = directory.as_ref().into();
let git_folder = base_dir.join(".git");
let node_folder = base_dir.join("node_modules");

let ignore_glob_set = build_glob_set(vec![
String::from("**/node_modules"),
String::from("**/.git"),
])
.expect("These static ignores always build");

// Use WalkDir instead of ignore::WalkBuilder because it's faster
WalkDir::new(&base_dir)
.into_iter()
.filter_entry(move |entry| {
!(entry.path().starts_with(&git_folder) || entry.path().starts_with(&node_folder))
let path = entry.path().to_string_lossy();
!ignore_glob_set.is_match(path.as_ref())
})
.filter_map(move |entry| {
entry
Expand Down

0 comments on commit c6fccb8

Please sign in to comment.