Search code examples
javascriptglobminimatch

What glob pattern to use for files inside a folder AND sub-folders?


I'm trying to run a npm task to lint against certain JS files.

Given the following list files:

/root.js                            // should be excluded
/js-src/lib/test.js                 // should be excluded
/js-src/lib/anotherTst.js           // should be excluded
/js-src/utilities/anotherModule.js  // should be included
/js-src/modules/myModule.js         // should be included
/js-src/common.js                   // should be included

The following pattern will work for all sub-folders excluding 'lib': ./js-src/!(lib)/**/*.js. However, common.js is ignored as is visible here on globtester

What should the mini match/globbing pattern be in order for this to work?


Solution

  • Try /**/!(lib)/*.js using globster.xyz