tinyglobby icon indicating copy to clipboard operation
tinyglobby copied to clipboard

Braced groups do not support ** wildcards consistently

Open davidje13 opened this issue 4 months ago • 3 comments

I originally raised this as a behaviour difference in a consumer project as a difference after switching to tinyglobby https://github.com/webpack-contrib/copy-webpack-plugin/issues/788#issuecomment-3207429950, but I was asked to raise it upstream since it's perceived to be a possible bug.

Using braced groups with initial ** wildcards behaves inconsistently. In my particular case:

Folder structure:

.well-known
- b.txt
regular
- c.txt
index.mjs
package.json
console.log(await glob('{.well-known/**/*,**/*}', { ignore: ['node_modules'] }));
// -> ['.well-known/b.txt', 'regular/c.txt']

i.e. the **/* part of the pattern is unable to detect top-level files like it would if not inside {}.

This applies regardless of the order of the branches.

A more contrived example shows that this inability to match ** with the top-level directory applies to all branches:

console.log(await glob('{**/*.mjs,**/*.json}', { ignore: ['node_modules'] }));
// -> []

davidje13 avatar Aug 21 '25 13:08 davidje13

thanks for reporting this, seems to be a picomatch issue, so we'd have to likely report it in there :P (and hope that maintainers look at it)

Image

SuperchupuDev avatar Aug 21 '25 15:08 SuperchupuDev

oddly enough, the issue affects micromatch too, but fast-glob which uses it doesn't have the issue 🤔

Image

SuperchupuDev avatar Aug 21 '25 15:08 SuperchupuDev

It was reported upstream in 2022!! https://github.com/micromatch/picomatch/issues/115 I tried to fix it with https://github.com/micromatch/picomatch/pull/150

fast-glob sidestep the issue by expand braces with micromatch before matching

xuanduc987 avatar Nov 18 '25 16:11 xuanduc987