4

Given the directory structure:

/Users/doge/very/amaze.js
/usr/local/bin/wow
/node_modules/
/css/
/css/somefile.css
/lib/
/somelib/
/anotherlib/somedir/finallib.js
/index.html
/somefile.test
/somelib/file.html
/firstdir/seconddir/file.css
/node_modules.txt

How would I only exclude the node_modules directory using extglob?

/!(node_modules)

The above matches everything at the root level except the node_modules directory and text file (which we want to include). It also doesn't follow matching directories recursively.

/!(node_modules)/**

This one is closer, but it also excludes all of the files in the root directory. Even if it included files at the root level, I'm guessing it would exclude the node_modules.txt file.

P.S. This is for file matching using grunt-ssh and minimatch node modules.

Inian
  • 80,270
  • 14
  • 142
  • 161
craig
  • 487
  • 2
  • 8
  • 18
  • 1
    Have you tried this one `/!(node_modules){,/**}` – Chen Dachao Jun 02 '17 at 11:13
  • Hi Larry, I actually came to that conclusion a while ago but forgot I had asked this question on SO. If you want to officially respond with this as the answer, I'll give you the upvote. – craig Jun 02 '17 at 17:26
  • Thanks, @craignewkirk, an official answer can make this question perfectly, and easy to find for others. – Chen Dachao Jun 03 '17 at 00:52

1 Answers1

4

This one can solve your problem: /!(node_modules){,/**}

Chen Dachao
  • 1,736
  • 2
  • 21
  • 36