title: Globs & NPM Minimatch: Match all files and directories recursively except for specific directories
body: <p>Given the directory structure:</p>
  
  <pre><code>/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
  </code></pre>
  
  <p>How would I only exclude the node_modules directory using extglob?</p>
  
  <pre><code>/!(node_modules)
  </code></pre>
  
  <p>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.</p>
  
  <pre><code>/!(node_modules)/**
  </code></pre>
  
  <p>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>
  
  <p>P.S. This is for file matching using <a href="https://github.com/israelroldan/grunt-ssh" rel="nofollow noreferrer">grunt-ssh</a> and <a href="https://github.com/isaacs/minimatch" rel="nofollow noreferrer">minimatch</a> node modules.</p>