Jason
Jason

Reputation: 11363

grunt file glob file extension pattern

I have a grunt task to traverse a folder structure for all jpg, jpeg and png files. Is there an easier way to do this compared to

images : {
    expand : true,
    flatten : true,
    cwd : "develop/",
    src : ["modules/**/*.jpg", "modules/**/*.jpeg", "modules/**/*.png"],
    dest : "build/resources/img/"
},

According to the documentations, the { .. } bracket for a file allows multiple options to be compared with for the containing files. However, the following do not work for src array values:

"modules/**/*{jpg, jpeg, png}"
"modules/**/*.{jpg, jpeg, png}"
"modules/**/*{.jpg, .jpeg, .png}"

and so therefore I was forced to do a straight glob pattern for each file extension

Upvotes: 0

Views: 229

Answers (1)

gfpacheco
gfpacheco

Reputation: 3215

There's extra spaces after the commas in your expression.

This should do it: "modules/**/*.{jpg,jpeg,png}"

Upvotes: 1

Related Questions