#StackBounty: #javascript #node.js #glob NodeJS&Glob: any number of filenames, filename extensions and files that must be excluded …

Bounty: 50

The following glob expression selects all .pug files except index.pug (filddle):


Now assume that we has managed to stop haml support, therefore all that related with haml must be removed from above expression. The question is how to reduce above expression without radical changing of it’s structure? This condition is important for creation of simple and the same time flexible algorithm of glob expressions generation.

Wrong solution (no matches among .pug files):


Below solution is also improper, because possibly in the future we would to add new filename extension support (e. g. .slim). To implement it, we must to radically change the algorithm that generates below expression.


Below solution is also improper because we can not exclude arbitrary files from it. What if we want to exclude index.pug and about.slim, but not index.slim and about.pug?


By other words: all above solution are not scale-able on any count of:
* filename that must be selected
* filename extensions which files must be selected
* filename with certain extension that must be excluded.

Important: In this question, we does not consider files receiving by glob, globby, gulp.src() etc. We considering single string generation.

And also: if above problem is impossible to solve by one string, please write such as (with explanation/commentary).

Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.