I've wrote a function to simplify writing exclude pattern, due to the fact that **
matches all children and the parent.
del.sync(extendNegGlobs(['public/assets/**', '!public/assets/goat.png']));
// is equivalent with
del.sync(['public/assets/**', '!public/assets/goat.png', '!public/assets', '!public']);
Here is my function:
function extendNegGlobs(arr) {
var ext = [];
var negs = {};
arr.forEach((g, i) => {
if ( g.slice(0,1) == '!' ) {
negs[g] = i;
}
});
Object.keys(negs).forEach((g) => {
var d;
if ( g.slice(-1) == '*' ) do {
g = path.dirname(d = g);
if ( g == '!' || g == '.' || g == d ) break;
if ( !(g in negs) ) {
negs[g] = ext.push(g);
}
}
while ( true );
});
return arr.concat(ext);
}
I don't pretend this is a complete/nice solution, but it might be a starting point to finding one!
Comments ?
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too