Skip to content

Request custom processPaths() callback #22

Open
@DRSDavidSoft

Description

@DRSDavidSoft

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions