node.js - Glob / minimatch: how to gulp.src() everything, then exclude folder but keep one file in it -


i have project this:

root   |-incl1   |-incl2   |- ...   |-excl1   |-excl2      |- .gitignore  <-- keep 1      |- (other files)  <-- exclude them 

i need write gulp.src() include folders except excl1 , excl2 but keep .gitignore file.

this code doesn't work:

gulp.src([   basedir + '/**',   '!' + basedir + '/{excl1, excl1/**}'   '!' + basedir + '/excl2/{**, !.gitignore}'  // <-- doesn't work ], {dot: true}) 

this seems work:

gulp.src([     basedir + '/**',                              // include     '!' + basedir + '/excl1{,/**}',               // exclude excl1 dir     '!' + basedir + '/excl2/**/!(.gitignore)',    // exclude excl2 dir, except .gitignore ], { dot: true }); 

excluding single file glob match tricky because there's no similar examples in minimatch docs.

https://github.com/isaacs/minimatch

"if pattern starts ! character, negated".


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -