
Security News
CISA Kills Off RSS Feeds for KEVs and Cyber Alerts
CISA is discontinuing official RSS support for KEV and cybersecurity alerts, shifting updates to email and social media, disrupting automation workflows.
gulp-custom-filter
Advanced tools
A gulp plugin to filter files by customized filters.
$ npm install --save-dev gulp-custom-filter
var filter = require('gulp-custom-filter');
var gulp = require('gulp');
var less = require('gulp-less');
function myFilter(file) {
return file.basename.startsWith('my_');
}
gulp.task('less', function() {
return gulp.src('./less/**/*.less')
.pipe(filter(myFilter))
.pipe(less())
.pipe(gulp.dest('./css')
});
This is equivalent to:
var filter = require('gulp-custom-filter');
var gulp = require('gulp');
var less = require('gulp-less');
gulp.task('less', function() {
return gulp.src('./less/**/my_*.less')
.pipe(less())
.pipe(gulp.dest('./css')
});
You may set any predicate function to a vinyl file.
Nagates filter conditions
var not = filter.not;
gulp.src('./less/**/*.less')
.pipe(filter(not(myFilter)) // will pass files which not satisfy myFilter
This filter passes less files which its name does not start with 'my_'.
Passes files which satisfy every filter conditions.
var and = filter.and;
gulp.src('./less/**/*.less')
.pipe(filter(and(myFilter1, myFilter2)) // will pass files which satisfy myFilter1 and myFilter2
Passes files which satisfy at least one of the filter conditions.
var or = filter.or;
gulp.src('./less/**/*.less')
.pipe(filter(or(myFilter1, myFilter2)) // will pass files which satisfy myFilter1 or myFilter2
Passes every files. This is equivalent function() { return true; }
var all = filter.all;
gulp.src('./less/**/*.less')
.pipe(filter(all())) // no file will be filtered out.
Passes no file. This is equivalent function() { return false; }
var none = filter.none;
gulp.src('./less/**/*.less')
.pipe(filter(none())) // no file will be passed.
Glob pattern filter for file name. Just a wrapper of minimatch.
var glob = filter.glob;
gulp.src('./**/*.*')
.pipe(filter(glob('./**/*.less'))).
pattern
: a string or an array of glob pattern.options
: optional options.Ignore list filter.
var ignore = filter.ignore;
gulp.src('./**/*.*')
.pipe(filter(ignore('.gitignore')))
filename
: filename to ignore file.gulp-custom-filter
accepts three type of predicate functions.
A predicate must have one or two argument(s).
It returns a boolean value true
/false
.
gulp.src('./**/*.*')
.pipe(filter(function(file, encode) {
return file.isBuffer();
});
To fail the predicate, just throw an error.
gulp.src('./**/*.*')
.pipe(filter(function(file, encode) {
throw new Error('error');
});
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.src('./**/*.*')
.pipe(filter(function(file, encode, done) {
setTimeout(function() {
done(null, file.isBuffer()); // 1st argument must be falsy.
}, 0);
});
To fail the predicate, call done
with the first argument of non-falsy value.
gulp.src('./**/*.*')
.pipe(filter(function(file, encode, done) {
setTimeout(function() {
done(new Error('error'));
}, 0);
});
A predicate must have one or two argument(s).
It returns a fulfilling promise of boolean value true
/false
.
gulp.src('./**/*.*')
.pipe(filter(function(file, encode) {
return Promise.resolve(file.isBuffer());
});
To fail the predicate, return a rejecting promise.
gulp.src('./**/*.*')
.pipe(filter(function(file, encode) {
return Promise.reject(new Error('error'));
});
v0.4.4
v0.4.3
v0.3.0
v0.2.5
FAQs
A gulp plugin to filter files by customized filters
We found that gulp-custom-filter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISA is discontinuing official RSS support for KEV and cybersecurity alerts, shifting updates to email and social media, disrupting automation workflows.
Security News
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
Research
Security News
Socket uncovers an npm Trojan stealing crypto wallets and BullX credentials via obfuscated code and Telegram exfiltration.