Skip to content

Commit

Permalink
fix **/.lua matching in the root
Browse files Browse the repository at this point in the history
  • Loading branch information
wez committed Aug 25, 2024
1 parent cfa6022 commit 9573218
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion filenamegen/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "filenamegen"
version = "0.2.6"
version = "0.2.7"
authors = ["Wez Furlong"]
edition = "2021"
description = "Shell-style filename generation aka globbing"
Expand Down
20 changes: 20 additions & 0 deletions filenamegen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,26 @@ mod test {
Ok(())
}

#[test]
fn test_lua_toml() -> anyhow::Result<()> {
let root = make_fixture()?;
touch_files_in(
&root,
&["simple.lua", "assets/policy-extras/bar.lua", "assets/policy-extras/shaping.toml"],
)?;
let glob = Glob::new("**/*.{lua,toml}")?;
assert_eq!(
glob.walk(&root),
vec![
PathBuf::from("assets/policy-extras/bar.lua"),
PathBuf::from("assets/policy-extras/shaping.toml"),
PathBuf::from("simple.lua"),
]
);

Ok(())
}

#[test]
fn test_more() -> anyhow::Result<()> {
let root = make_fixture()?;
Expand Down
4 changes: 2 additions & 2 deletions filenamegen/src/recursivewalker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ impl RecursiveWalker {
Node::RecursiveMatch.append_regex(&mut pattern);
for node in nodes {
#[cfg(not(windows))]
pattern.push('/');
pattern.push_str("/?");
#[cfg(windows)]
pattern.push_str("[/\\\\]");
pattern.push_str("[/\\\\]?");
node.append_regex(&mut pattern);
}
pattern.push('$');
Expand Down

0 comments on commit 9573218

Please sign in to comment.