pilau
pilau

Reputation: 6723

Node.js glob - matching a path under any directory

With node.js globbing, I want to match some path, under any subdirectory. I hope my code example is clearer than my wording:

app/themes/*/images/icons/**/*.png

So, imagine the following:

app
|-- themes
|   |-- theme1
|   |   `-- images
|   |       `-- icons
|   |           `-- home-icon.png
|   `-- theme2
|       `-- images
|           `-- icons
|               `-- home-icon.png

It should match both home-icon.pngs, in both theme1 and theme2.

Upvotes: 0

Views: 4482

Answers (1)

unobf
unobf

Reputation: 7244

app/themes/*/images/icons/*.png

Code to try in Node console

var g = require('glob');
g('app/themes/*/images/icons/*.png', function (er, files) {
    console.log(files);
});

Should list the files that match

Upvotes: 3

Related Questions