Skip to content

Commit 52df753

Browse files
mjeanroysindresorhus
authored andcommitted
Remove deprecated gulp-util dependency (#86)
1 parent b9fb0bc commit 52df753

File tree

3 files changed

+37
-36
lines changed

3 files changed

+37
-36
lines changed

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22
const path = require('path');
3-
const gutil = require('gulp-util');
3+
const PluginError = require('plugin-error');
44
const multimatch = require('multimatch');
55
const streamfilter = require('streamfilter');
66

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

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

1515
return streamfilter((file, enc, cb) => {

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,13 @@
3030
"globbing"
3131
],
3232
"dependencies": {
33-
"gulp-util": "^3.0.6",
3433
"multimatch": "^2.0.0",
34+
"plugin-error": "^0.1.2",
3535
"streamfilter": "^1.0.5"
3636
},
3737
"devDependencies": {
3838
"mocha": "*",
39+
"vinyl": "^2.1.0",
3940
"xo": "*"
4041
}
4142
}

test.js

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/* eslint-env mocha */
33
const path = require('path');
44
const assert = require('assert');
5-
const gutil = require('gulp-util');
5+
const Vinyl = require('vinyl');
66
const filter = require('.');
77

88
describe('filter()', () => {
@@ -20,12 +20,12 @@ describe('filter()', () => {
2020
cb();
2121
});
2222

23-
stream.write(new gutil.File({
23+
stream.write(new Vinyl({
2424
base: __dirname,
2525
path: path.join(__dirname, 'included.js')
2626
}));
2727

28-
stream.write(new gutil.File({
28+
stream.write(new Vinyl({
2929
base: __dirname,
3030
path: path.join(__dirname, 'ignored.js')
3131
}));
@@ -48,12 +48,12 @@ describe('filter()', () => {
4848
cb();
4949
});
5050

51-
stream.write(new gutil.File({
51+
stream.write(new Vinyl({
5252
base: __dirname,
5353
path: path.join(__dirname, 'included.js')
5454
}));
5555

56-
stream.write(new gutil.File({
56+
stream.write(new Vinyl({
5757
base: __dirname,
5858
path: path.join(__dirname, 'ignored.js')
5959
}));
@@ -76,12 +76,12 @@ describe('filter()', () => {
7676
cb();
7777
});
7878

79-
stream.write(new gutil.File({
79+
stream.write(new Vinyl({
8080
base: __dirname,
8181
path: path.join(__dirname, 'nested', 'resource.js')
8282
}));
8383

84-
stream.write(new gutil.File({
84+
stream.write(new Vinyl({
8585
base: __dirname,
8686
path: path.join(__dirname, 'nested', 'resource.css')
8787
}));
@@ -106,8 +106,8 @@ describe('filter()', () => {
106106
cb();
107107
});
108108

109-
stream.write(new gutil.File({path: 'included.js'}));
110-
stream.write(new gutil.File({path: 'ignored.js'}));
109+
stream.write(new Vinyl({path: 'included.js'}));
110+
stream.write(new Vinyl({path: 'ignored.js'}));
111111
stream.end();
112112
});
113113

@@ -126,10 +126,10 @@ describe('filter()', () => {
126126
cb();
127127
});
128128

129-
stream.write(new gutil.File({path: 'included.js'}));
130-
stream.write(new gutil.File({path: 'package.json'}));
131-
stream.write(new gutil.File({path: '.jshintrc'}));
132-
stream.write(new gutil.File({path: 'app.js'}));
129+
stream.write(new Vinyl({path: 'included.js'}));
130+
stream.write(new Vinyl({path: 'package.json'}));
131+
stream.write(new Vinyl({path: '.jshintrc'}));
132+
stream.write(new Vinyl({path: 'app.js'}));
133133
stream.end();
134134
});
135135

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

150150
// Mimic `gulp.src('test/**/*.js')`
151-
stream.write(new gutil.File({
151+
stream.write(new Vinyl({
152152
base: path.join(__dirname, 'test'),
153153
path: path.join(__dirname, 'test', 'included.js')
154154
}));
155155

156-
stream.write(new gutil.File({
156+
stream.write(new Vinyl({
157157
base: __dirname,
158158
path: path.join(__dirname, 'ignored.js')
159159
}));
@@ -176,7 +176,7 @@ describe('filter()', () => {
176176
cb();
177177
});
178178

179-
stream.write(new gutil.File({
179+
stream.write(new Vinyl({
180180
path: gfile
181181
}));
182182

@@ -210,9 +210,9 @@ describe('filter.restore', () => {
210210
cb();
211211
});
212212

213-
stream.write(new gutil.File({path: 'package.json'}));
214-
stream.write(new gutil.File({path: 'app.js'}));
215-
stream.write(new gutil.File({path: 'package2.json'}));
213+
stream.write(new Vinyl({path: 'package.json'}));
214+
stream.write(new Vinyl({path: 'app.js'}));
215+
stream.write(new Vinyl({path: 'package2.json'}));
216216
stream.end();
217217
});
218218

@@ -238,9 +238,9 @@ describe('filter.restore', () => {
238238
cb();
239239
});
240240

241-
streamFilter1.write(new gutil.File({path: 'package.json'}));
242-
streamFilter1.write(new gutil.File({path: 'app.js'}));
243-
streamFilter1.write(new gutil.File({path: 'main.css'}));
241+
streamFilter1.write(new Vinyl({path: 'package.json'}));
242+
streamFilter1.write(new Vinyl({path: 'app.js'}));
243+
streamFilter1.write(new Vinyl({path: 'main.css'}));
244244
streamFilter1.end();
245245
});
246246

@@ -259,9 +259,9 @@ describe('filter.restore', () => {
259259
cb();
260260
});
261261

262-
stream.write(new gutil.File({path: 'package.json'}));
263-
stream.write(new gutil.File({path: 'app.js'}));
264-
stream.write(new gutil.File({path: 'package2.json'}));
262+
stream.write(new Vinyl({path: 'package.json'}));
263+
stream.write(new Vinyl({path: 'app.js'}));
264+
stream.write(new Vinyl({path: 'package2.json'}));
265265
stream.end();
266266
});
267267

@@ -276,7 +276,7 @@ describe('filter.restore', () => {
276276
setImmediate(() => {
277277
restoreStream.end();
278278
setImmediate(() => {
279-
stream.write(new gutil.File({path: 'app2.js'}));
279+
stream.write(new Vinyl({path: 'app2.js'}));
280280
stream.end();
281281
});
282282
});
@@ -290,8 +290,8 @@ describe('filter.restore', () => {
290290
cb();
291291
});
292292

293-
stream.write(new gutil.File({path: 'package.json'}));
294-
stream.write(new gutil.File({path: 'app.js'}));
293+
stream.write(new Vinyl({path: 'package.json'}));
294+
stream.write(new Vinyl({path: 'app.js'}));
295295
});
296296

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

318318
stream.pipe(restoreStream);
319-
stream.write(new gutil.File({path: 'package.json'}));
320-
stream.write(new gutil.File({path: 'app.js'}));
321-
stream.write(new gutil.File({path: 'package2.json'}));
322-
stream.write(new gutil.File({path: 'app2.js'}));
319+
stream.write(new Vinyl({path: 'package.json'}));
320+
stream.write(new Vinyl({path: 'app.js'}));
321+
stream.write(new Vinyl({path: 'package2.json'}));
322+
stream.write(new Vinyl({path: 'app2.js'}));
323323
});
324324

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

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

332332
stream.on('finish', cb);

0 commit comments

Comments
 (0)