0

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.

Beee
  • 151
  • 8

3 Answers3

2

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.

try-catch-finally
  • 7,436
  • 6
  • 46
  • 67
  • I agree...That I got from the docs...but the comma is puzzling us, since it's normally used to separate something, but not here. – Beee Mar 11 '19 at 08:05
1

{,**/}*.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

Domajno
  • 587
  • 1
  • 5
  • 13
0

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

Ponpon32
  • 2,150
  • 2
  • 15
  • 26