Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): handle negative star glob better #19241

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions packages/nx/src/native/utils/glob.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ fn convert_glob(glob: &str) -> anyhow::Result<Vec<String>> {
globs.push(format!(
"!{}",
SINGLE_PATTERN_REGEX
.replace(&glob, |caps: &regex::Captures| { caps[1].to_string() })
.replace(&glob, |caps: &regex::Captures| { format!("{}*", &caps[1]) })
.replace('!', "")
));
} else {
Expand Down Expand Up @@ -197,7 +197,7 @@ mod test {
#[test]
fn convert_globs_single_negative() {
let negative_single_dir = convert_glob("packages/!(package-a)*").unwrap();
assert_eq!(negative_single_dir, ["packages/*", "!packages/package-a"]);
assert_eq!(negative_single_dir, ["packages/*", "!packages/package-a*"]);
}

#[test]
Expand Down Expand Up @@ -318,6 +318,8 @@ mod test {
assert!(glob_set.is_match("packages/package-c"));
// no matches
assert!(!glob_set.is_match("packages/package-a"));
assert!(!glob_set.is_match("packages/package-a-b"));
assert!(!glob_set.is_match("packages/package-a-b/nested"));
assert!(!glob_set.is_match("packages/package-b/nested"));
}
}