Skip to content

Commit

Permalink
Require Gulp 4
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Aug 18, 2019
1 parent b0e9393 commit ffda884
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,11 @@
"streamfilter": "^3.0.0"
},
"devDependencies": {
"mocha": "^6.1.4",
"mocha": "^6.2.0",
"vinyl": "^2.1.0",
"xo": "^0.24.0"
},
"peerDependencies": {
"gulp": ">=4"
}
}
18 changes: 9 additions & 9 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const gulp = require('gulp');
const uglify = require('gulp-uglify');
const filter = require('gulp-filter');

gulp.task('default', () => {
exports.default = () => {
// Create filter instance inside task function
const f = filter(['**', '!*src/vendor']);

Expand All @@ -33,7 +33,7 @@ gulp.task('default', () => {
// Run them through a plugin
.pipe(uglify())
.pipe(gulp.dest('dist'));
});
};
```

### Restoring filtered files
Expand All @@ -43,7 +43,7 @@ const gulp = require('gulp');
const uglify = require('gulp-uglify');
const filter = require('gulp-filter');

gulp.task('default', () => {
exports.default = () => {
// Create filter instance inside task function
const f = filter(['**', '!*src/vendor'], {restore: true});

Expand All @@ -55,7 +55,7 @@ gulp.task('default', () => {
// Bring back the previously filtered out files (optional)
.pipe(f.restore)
.pipe(gulp.dest('dist'));
});
};
```

### Multiple filters
Expand All @@ -68,7 +68,7 @@ const less = require('gulp-less');
const concat = require('gulp-concat');
const filter = require('gulp-filter');

gulp.task('default', () => {
exports.default = () => {
const jsFilter = filter('**/*.js', {restore: true});
const lessFilter = filter('**/*.less', {restore: true});

Expand All @@ -80,7 +80,7 @@ gulp.task('default', () => {
.pipe(less())
.pipe(lessFilter.restore)
.pipe(gulp.dest('out/'));
});
};
```

### Restore as a file source
Expand All @@ -92,7 +92,7 @@ const gulp = require('gulp');
const uglify = require('gulp-uglify');
const filter = require('gulp-filter');

gulp.task('default', () => {
exports.default = () => {
const f = filter(['**', '!*src/vendor'], {restore: true, passthrough: false});

const stream = gulp.src('src/**/*.js')
Expand All @@ -106,13 +106,13 @@ gulp.task('default', () => {
f.restore.pipe(gulp.dest('vendor-dist'));

return stream;
});
};
```


## API

### filter(pattern, [options])
### filter(pattern, options?)

Returns a [transform stream](https://nodejs.org/api/stream.html#stream_class_stream_transform) with a [.restore](#optionsrestore) property.

Expand Down

0 comments on commit ffda884

Please sign in to comment.