I have the following line in my Gruntfile
.
js
files: ['<%= yeoman.app %>/scripts/{,*/}*.coffee'],
Could someone be so kind as tell me what {,*/}*
mean? I know it's trying to match all .coffee
files in the scripts folder, but I want to know how it does that.
The {,*/}
matches one or zero directories between scripts and the .coffee file. Inside the {} there are actually two matching terms separated by a comma. One is blank, represented by no characters to the left of the comma. One is any number of characters and a forward slash. The final * matches the filename before the .coffee extension.
By the way, this is not regular expressions, it's globbing.
According to the documentation:
Also, because this is JavaScript, you're not limited to JSON; you may use any valid JavaScript here. You may even programmatically generate the configuration if necessary.
It looks like {,*/}*
is a JSON
match for:
{
'' = empty space matches no character
, = or
* = Any Characters (except slash) (wildcard)
/ = literal slash
}
* = Any Characters (except slash) (wildcard)
Update Found another resource:
Globbing patterns
It is often impractical to specify all source filepaths individually, so Grunt supports filename expansion (also know as globbing) via the built-in node-glob and minimatch libraries.
While this isn't a comprehensive tutorial on globbing patterns, know that in a filepath:
* matches any number of characters, but not /
? matches a single character, but not /
** matches any number of characters, including /, as long as it's the only thing in a path part
{} allows for a comma-separated list of "or" expressions
! at the beginning of a pattern will negate the match
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With