Skip to content

Commit

Permalink
fix: nested ignored packages (#91)
Browse files Browse the repository at this point in the history
  • Loading branch information
QuiiBz authored Aug 22, 2024
1 parent be929db commit 7967935
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 4 deletions.
3 changes: 3 additions & 0 deletions fixtures/ignore-paths/packages/a/b/d/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"name": "d"
}
3 changes: 3 additions & 0 deletions fixtures/ignore-paths/packages/a/b/e/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"name": "e"
}
3 changes: 3 additions & 0 deletions fixtures/ignore-paths/packages/a/c/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"name": "c"
}
2 changes: 2 additions & 0 deletions fixtures/ignore-paths/pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ packages:
- 'docs'
- '!packages/abc'
- '!packages/d*'
- '!packages/a/*'
- 'packages/a/b/*'
12 changes: 8 additions & 4 deletions src/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,9 @@ pub fn collect_packages(args: &Args) -> Result<PackagesList> {
let mut is_excluded = false;

for excluded_path in &excluded_paths {
if real_path.starts_with(excluded_path) {
if real_path.starts_with(excluded_path)
&& !real_path.replace(excluded_path, "").contains('/')
{
is_excluded = true;
break;
}
Expand Down Expand Up @@ -480,16 +482,18 @@ mod test {
} = result.unwrap();

assert_eq!(root_package.get_name(), "ignore-paths");
assert_eq!(packages.len(), 2);
assert_eq!(packages.len(), 4);

let mut packages = packages
.into_iter()
.map(|package| package.get_name().clone().unwrap().to_string())
.collect::<Vec<_>>();
packages.sort();

assert_eq!(packages[0], "docs");
assert_eq!(packages[1], "ghi");
assert_eq!(packages[0], "d");
assert_eq!(packages[1], "docs");
assert_eq!(packages[2], "e");
assert_eq!(packages[3], "ghi");
}

#[test]
Expand Down

0 comments on commit 7967935

Please sign in to comment.