Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request custom processPaths() callback #22

Open
DRSDavidSoft opened this issue Apr 7, 2019 · 0 comments
Open

Request custom processPaths() callback #22

DRSDavidSoft opened this issue Apr 7, 2019 · 0 comments

Comments

@DRSDavidSoft
Copy link

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:

  1. Using fancy-log instead of console.warn to match the rest of output
  2. 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
  3. Process custom extensions (e.g. *.global-less and *.local-less) as css/less files
  4. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant