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

Remove deprecated gulp-util dependency #86

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';
const path = require('path');
const gutil = require('gulp-util');
const PluginError = require('plugin-error');
const multimatch = require('multimatch');
const streamfilter = require('streamfilter');

Expand All @@ -9,7 +9,7 @@ module.exports = (pattern, options) => {
options = options || {};

if (!Array.isArray(pattern) && typeof pattern !== 'function') {
throw new gutil.PluginError('gulp-filter', '`pattern` should be a string, array, or function');
throw new PluginError('gulp-filter', '`pattern` should be a string, array, or function');
}

return streamfilter((file, enc, cb) => {
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@
"globbing"
],
"dependencies": {
"gulp-util": "^3.0.6",
"multimatch": "^2.0.0",
"plugin-error": "^0.1.2",
"streamfilter": "^1.0.5"
},
"devDependencies": {
"mocha": "*",
"vinyl": "^2.1.0",
"xo": "*"
}
}
66 changes: 33 additions & 33 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/* eslint-env mocha */
const path = require('path');
const assert = require('assert');
const gutil = require('gulp-util');
const Vinyl = require('vinyl');
const filter = require('.');

describe('filter()', () => {
Expand All @@ -20,12 +20,12 @@ describe('filter()', () => {
cb();
});

stream.write(new gutil.File({
stream.write(new Vinyl({
base: __dirname,
path: path.join(__dirname, 'included.js')
}));

stream.write(new gutil.File({
stream.write(new Vinyl({
base: __dirname,
path: path.join(__dirname, 'ignored.js')
}));
Expand All @@ -48,12 +48,12 @@ describe('filter()', () => {
cb();
});

stream.write(new gutil.File({
stream.write(new Vinyl({
base: __dirname,
path: path.join(__dirname, 'included.js')
}));

stream.write(new gutil.File({
stream.write(new Vinyl({
base: __dirname,
path: path.join(__dirname, 'ignored.js')
}));
Expand All @@ -76,12 +76,12 @@ describe('filter()', () => {
cb();
});

stream.write(new gutil.File({
stream.write(new Vinyl({
base: __dirname,
path: path.join(__dirname, 'nested', 'resource.js')
}));

stream.write(new gutil.File({
stream.write(new Vinyl({
base: __dirname,
path: path.join(__dirname, 'nested', 'resource.css')
}));
Expand All @@ -106,8 +106,8 @@ describe('filter()', () => {
cb();
});

stream.write(new gutil.File({path: 'included.js'}));
stream.write(new gutil.File({path: 'ignored.js'}));
stream.write(new Vinyl({path: 'included.js'}));
stream.write(new Vinyl({path: 'ignored.js'}));
stream.end();
});

Expand All @@ -126,10 +126,10 @@ describe('filter()', () => {
cb();
});

stream.write(new gutil.File({path: 'included.js'}));
stream.write(new gutil.File({path: 'package.json'}));
stream.write(new gutil.File({path: '.jshintrc'}));
stream.write(new gutil.File({path: 'app.js'}));
stream.write(new Vinyl({path: 'included.js'}));
stream.write(new Vinyl({path: 'package.json'}));
stream.write(new Vinyl({path: '.jshintrc'}));
stream.write(new Vinyl({path: 'app.js'}));
stream.end();
});

Expand All @@ -148,12 +148,12 @@ describe('filter()', () => {
});

// Mimic `gulp.src('test/**/*.js')`
stream.write(new gutil.File({
stream.write(new Vinyl({
base: path.join(__dirname, 'test'),
path: path.join(__dirname, 'test', 'included.js')
}));

stream.write(new gutil.File({
stream.write(new Vinyl({
base: __dirname,
path: path.join(__dirname, 'ignored.js')
}));
Expand All @@ -176,7 +176,7 @@ describe('filter()', () => {
cb();
});

stream.write(new gutil.File({
stream.write(new Vinyl({
path: gfile
}));

Expand Down Expand Up @@ -210,9 +210,9 @@ describe('filter.restore', () => {
cb();
});

stream.write(new gutil.File({path: 'package.json'}));
stream.write(new gutil.File({path: 'app.js'}));
stream.write(new gutil.File({path: 'package2.json'}));
stream.write(new Vinyl({path: 'package.json'}));
stream.write(new Vinyl({path: 'app.js'}));
stream.write(new Vinyl({path: 'package2.json'}));
stream.end();
});

Expand All @@ -238,9 +238,9 @@ describe('filter.restore', () => {
cb();
});

streamFilter1.write(new gutil.File({path: 'package.json'}));
streamFilter1.write(new gutil.File({path: 'app.js'}));
streamFilter1.write(new gutil.File({path: 'main.css'}));
streamFilter1.write(new Vinyl({path: 'package.json'}));
streamFilter1.write(new Vinyl({path: 'app.js'}));
streamFilter1.write(new Vinyl({path: 'main.css'}));
streamFilter1.end();
});

Expand All @@ -259,9 +259,9 @@ describe('filter.restore', () => {
cb();
});

stream.write(new gutil.File({path: 'package.json'}));
stream.write(new gutil.File({path: 'app.js'}));
stream.write(new gutil.File({path: 'package2.json'}));
stream.write(new Vinyl({path: 'package.json'}));
stream.write(new Vinyl({path: 'app.js'}));
stream.write(new Vinyl({path: 'package2.json'}));
stream.end();
});

Expand All @@ -276,7 +276,7 @@ describe('filter.restore', () => {
setImmediate(() => {
restoreStream.end();
setImmediate(() => {
stream.write(new gutil.File({path: 'app2.js'}));
stream.write(new Vinyl({path: 'app2.js'}));
stream.end();
});
});
Expand All @@ -290,8 +290,8 @@ describe('filter.restore', () => {
cb();
});

stream.write(new gutil.File({path: 'package.json'}));
stream.write(new gutil.File({path: 'app.js'}));
stream.write(new Vinyl({path: 'package.json'}));
stream.write(new Vinyl({path: 'app.js'}));
});

it('should pass files as they come', cb => {
Expand All @@ -316,17 +316,17 @@ describe('filter.restore', () => {
});

stream.pipe(restoreStream);
stream.write(new gutil.File({path: 'package.json'}));
stream.write(new gutil.File({path: 'app.js'}));
stream.write(new gutil.File({path: 'package2.json'}));
stream.write(new gutil.File({path: 'app2.js'}));
stream.write(new Vinyl({path: 'package.json'}));
stream.write(new Vinyl({path: 'app.js'}));
stream.write(new Vinyl({path: 'package2.json'}));
stream.write(new Vinyl({path: 'app2.js'}));
});

it('should work when restore stream is not used', cb => {
const stream = filter('*.json');

for (let i = 0; i < stream._writableState.highWaterMark + 1; i++) {
stream.write(new gutil.File({path: 'nonmatch.js'}));
stream.write(new Vinyl({path: 'nonmatch.js'}));
}

stream.on('finish', cb);
Expand Down