Reputation: 567
I need to match the word "cache" in either a folder or filename, and it also has to end in .test.js
Example:
/Users/doge/lib/cache/index.js // should not match
/Users/doge/lib/cache/index.test.js // should match
/Users/doge/lib/something/index.test.js // should not match
/Users/doge/lib/something/cache.test.js // should match
I've tried /**/*cache*.test.js
but that doens't seem to work.
Upvotes: 2
Views: 3589
Reputation: 637
How about **/{*cache*/*,*cache*}.test.js
? This is assuming you are using minimatch library (which is likely if you are working with JavaScript). Try using globster.xyz to test and improve your pattern.
In the pattern I mentioned {}
are a feature called brace expansion. This pattern will be expanded into two separate patterns: one for matching a directory name and the other for matching filename **/*cache*/*.test.js
, **/*cache*.test.js
. This is still not perfect because the folder containing cache
will have to be exactly one level above the file itself but maybe it works for you.
Upvotes: 3