Match all files exclude multiple directories with glob pattern

71 views Asked by At

I'm trying to write a glob to match all files exclude two directories: app/home and node_modules/package1

/test/app/home
/test/app/list
/test/app/Test1
/test/app/Test2
/test/app/Test3
/test/node_modules/package1
/test/a/home
/test/b/package1

**/!(home|package1) works well to exclude home and package1 Link

I want something like **/!(app/home|node_modules/package1), however it doesn't match anything

1

There are 1 answers

1
jeremiah_brannon On

You can match multiple files by changing your exclusion pattern to only include the section that will be different in your exclusion pattern.

Instead of:

**/!(app/home|node_modules/package1)

Try:

**/app/!(home|node_modules)/package1