Reputation: 8424
I have the following file hierarchy:
scripts
someConfigFile.js
anotherConfigFile.js
someModuleDirectory
someModule.js
anotherModuleDirectory
anotherModule.js
subDirectory
thirdModule.js
I want to match all the files in the module directories, but excude the config files contained in the scripts
directory itself, using Glob:
var glob = require('glob');
console.log(glob.sync(unknownGlobPattern));
Required output (unordered):
[
'someModuleDirectory/someModule.js',
'anotherModuleDirectory/anotherModule.js',
'anotherModuleDirectory/subDirectory/thirdModule.js'
]
Upvotes: 9
Views: 41697
Reputation: 6220
The following glob should work:
['./scripts/**/*', '!./scripts/*']
First part will include all files in all subdirectories. Second part will exclude files in starting directory.
Upvotes: 11