On the GruntJS site, it has a section on globbing patterns, but there is something I'm a little confused on.
foo/**/*.js
will match all files ending with.js
in thefoo/
subdirectory and all of its subdirectories.
I see that the double asterisk matches all paths including the /
but if a file was in the foo
path, would that mean that it's trying to match a path called foo//*.js
?
Before I found that, I was trying something like foo/{,**}*.js
but that never really did what I wanted and I am a little confused on why that didn't work.
The double asterisk means that the pattern should perform a recursive match; i.e. look through all subdirectories it finds. For example, the pattern will match:
1. foo/bar.js
2. foo/baz.js
3. foo/bar/baz.js
4. foo/bar/baz/qux.js
It will not match a foo.txt
file. Although, a pattern such as foo/**
will match everything recursively (txt
, js
, css
etc).
Whereas, a pattern such as foo/*.js
will only match 1 and 2 because it is not a recursive pattern.