Beee
Beee

Reputation: 150

What does this wildcard mean?

I have a grunt file which has several commands. One part was written by a colleague who's left, but we can't find an explanation what it means exactly.

It does what it should do, but knowing what is exactly, is something we don't :)

This is the code:

dist: {
    files: [{
        expand: true,
        cwd: '<%= config.tmp %>/styles/',
        src: '{,**/}*.css',
        dest: '<%= config.tmp %>/styles/'
    }]
}

The part we're not sure is {,**/} on line 5.

Upvotes: 0

Views: 160

Answers (3)

try-catch-finally
try-catch-finally

Reputation: 7634

From the documentation:

{} allows for a comma-separated list of "or" expressions

Thus,

'{,**/}*.css',

will match *.css and **/*.css.

The first pattern inside the brace is redundant, since the second one should already match .css files in the current/root directory.

Upvotes: 2

Domajno
Domajno

Reputation: 637

{,**/}*.css curly braces inside that pattern represent the feature known as Brace expansion. Internally grunt is using Minimatch library which supports that feature. List of comma separated patterns inside them will be expanded first into two patterns *.css and **/*.css in your case. You can test your pattern using globster.xyz

Upvotes: 1

Ponpon32
Ponpon32

Reputation: 2200

A great answer by sotirios-delimanolis:

When to use ** (double star) in glob syntax within JAVA

The short story is that if you use one star than nested paths will ignored:

/a/a/a.css - ignored

The comma inside the curly braces it is what it is so files/directories with comma inside will not ignored:

dsadsad,dasdsadas/a.css

Upvotes: 0

Related Questions