Skip to content

Commit

Permalink
fix(core): use relative .nxignore when walking workspace
Browse files Browse the repository at this point in the history
  • Loading branch information
Cammisuli committed Nov 30, 2023
1 parent afafb79 commit 23205d3
Showing 1 changed file with 32 additions and 4 deletions.
36 changes: 32 additions & 4 deletions packages/nx/src/native/walker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,13 @@ where
P: AsRef<Path>,
{
let directory = directory.as_ref();
let nx_ignore = directory.join(".nxignore");

let ignore_glob_set =
build_glob_set(&["**/node_modules", "**/.git"]).expect("These static ignores always build");

let mut walker = WalkBuilder::new(directory);
walker.hidden(false);
walker.add_custom_ignore_filename(&nx_ignore);
walker.add_custom_ignore_filename(".nxignore");

// We should make sure to always ignore node_modules and the .git folder
walker.filter_entry(move |entry| {
Expand Down Expand Up @@ -159,6 +158,26 @@ mod test {
.child("grand_child.txt")
.write_str("data")
.unwrap();
temp_dir
.child("v1")
.child("packages")
.child("pkg-a")
.child("pkg-a.txt")
.write_str("data")
.unwrap();
temp_dir
.child("v1")
.child("packages")
.child("pkg-b")
.child("pkg-b.txt")
.write_str("data")
.unwrap();
temp_dir
.child("packages")
.child("pkg-c")
.child("pkg-c.txt")
.write_str("data")
.unwrap();

// add nxignore file
temp_dir
Expand All @@ -167,20 +186,29 @@ mod test {
r"baz/
nested/child.txt
nested/child-two/
# this should only ignore root level packages, not nested
/packages
",
)
.unwrap();

let mut file_names = nx_walker(temp_dir)
.into_iter()
.map(|(_, p)| p.to_normalized_string())
.collect::<Vec<_>>();

file_names.sort();

assert_eq!(
file_names,
vec!(".nxignore", "bar.txt", "foo.txt", "test.txt")
vec!(
".nxignore",
"bar.txt",
"foo.txt",
"test.txt",
"v1/packages/pkg-a/pkg-a.txt",
"v1/packages/pkg-b/pkg-b.txt"
)
);
}
}

0 comments on commit 23205d3

Please sign in to comment.