less-plugin-glob
less-plugin-glob copied to clipboard
Request custom `processPaths()` callback
feature request
Thank you for creating this awesome plugin!
I was wondering if I could ask for a feature to be added to it.
Could you please add a method to pass a custom processPaths()
filter to the plugin?
I was thinking something such as lessPluginGlob.options({filter: myFunc})
) in order to pass a function.
reasoning
I need to customize the filter in my gulp workflow for the following reasons:
- Using fancy-log instead of
console.warn
to match the rest of output - Either ignoring the "Here is non-less file:" warnings for some extensions (e.g.
*.disabled
), or displaying custom messages (e.g.File skipped: <name>.disabled
1 - Process custom extensions (e.g.
*.global-less
and*.local-less
) as css/less files - Using chalk in Node
1 The reason for this is that I sometimes rename my filename.less
to filename.less.disabled
in order to exclude it from the glob, without needing to write an exclusion rule.
Here's an example function that I would want to pass:
function processPaths(paths) {
return paths.filter(function(filepath) {
var ext = path.extname(filepath);
if( ['less', 'css', 'custom'].indexOf(ext.replace(/^\./, '')) > -1 )
return true;
if ( ext === '.disabled' )
logger.warn(chalk`{yellow Less file skipped:} ${filepath}`);
else console.warn(chalk`{yellow Here is non-less file:} ${filepath}, {red ignored}`);
return false;
});
}
n.b.
I believe this would be a safe (i.e. non-breaking) change.