Skip to content

Commit

Permalink
fix(core): handle negative star glob better (#19241)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cammisuli committed Sep 20, 2023
1 parent 6b16230 commit 3300fbd
Showing 1 changed file with 4 additions and 2 deletions.
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"));
}
}

0 comments on commit 3300fbd

Please sign in to comment.