gulp-custom-filter
A gulp plugin to filter files by customized filters.
Install
$ npm install --save-dev gulp-custom-filter
Usage
var filter = ;var gulp = ;var less = ; { return filebasename;} gulp
This is equivalent to:
var filter = ;var gulp = ;var less = ; gulp
You may set any predicate function to a vinyl file.
Basic filters
filter.not(fn)
Nagates filter conditions
var not = filternot; gulp
This filter passes less files which its name does not start with 'my_'.
filter.and(fn1, fn2, ...)
Passes files which satisfy every filter conditions.
var and = filterand; gulp
filter.or(fn1, fn2, ...)
Passes files which satisfy at least one of the filter conditions.
var or = filteror; gulp
filter.all()
Passes every files. This is equivalent function() { return true; }
var all = filterall; gulp // no file will be filtered out.
filter.none()
Passes no file. This is equivalent function() { return false; }
var none = filternone; gulp // no file will be passed.
Filename pattern filters
filter.glob(pattern, options)
Glob pattern filter for file name. Just a wrapper of minimatch.
var glob = filterglob; gulp
pattern
: a string or an array of glob pattern.options
: optional options.
filter.ignore(filename)
Ignore list filter.
var ignore = filterignore; gulp
filename
: filename to ignore file.
Filter development guide
gulp-custom-filter
accepts three type of predicate functions.
Simple boolean predicates: function(file, [encode]): boolean
A predicate must have one or two argument(s).
It returns a boolean value true
/false
.
gulp
To fail the predicate, just throw an error.
gulp
Asynchronous predicates: function(file, [encode], done: function(err, result)): void
A predicate must have three arguments. The third argument is a callback function to settle a result.
Call done
with the second argument of true
/false
.
gulp
To fail the predicate, call done
with the first argument of non-falsy value.
gulp
Promise predicates: function(file, done: function(err, result)): Promise.
A predicate must have one or two argument(s).
It returns a fulfilling promise of boolean value true
/false
.
gulp
To fail the predicate, return a rejecting promise.
gulp
Release Notes
-
v0.3.0
- Update library dependency
- Update supporting version of Node.js
- Now we support Node 6 or higher
-
v0.2.5
- Update supporting version of Node.js
- Fix assertion error message of or() filter
License
- MIT License
- see LICENSE