Skip to content

Commit 3a3b465

Browse files
TheDancingCodejoakimbeng
authored andcommitted
fix: drop dependency on deprecated gulp-util (#236)
Closes #235
1 parent cf66da0 commit 3a3b465

File tree

5 files changed

+39
-34
lines changed

5 files changed

+39
-34
lines changed

Diff for: package.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,13 @@
3030
"commitmsg": "commitlint -e"
3131
},
3232
"dependencies": {
33+
"ansi-colors": "^1.0.1",
3334
"arrify": "^1.0.1",
3435
"escape-string-regexp": "^1.0.5",
3536
"event-stream": "^3.1.0",
37+
"fancy-log": "^1.3.2",
3638
"group-array": "^0.3.0",
37-
"gulp-util": "^3.0.0",
39+
"plugin-error": "^0.1.2",
3840
"stream-to-array": "^2.3.0",
3941
"through2": "^2.0.1"
4042
},
@@ -46,6 +48,7 @@
4648
"semantic-release": "^12.4.1",
4749
"should": "^4.0.4",
4850
"strip-color": "^0.1.0",
51+
"vinyl": "^2.1.0",
4952
"xo": "^0.13.0"
5053
},
5154
"engines": {

Diff for: src/inject/index.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
'use strict';
22
var through2 = require('through2');
3-
var gutil = require('gulp-util');
3+
var fancyLog = require('fancy-log');
4+
var PluginError = require('plugin-error');
5+
var colors = require('ansi-colors');
46
var streamToArray = require('stream-to-array');
57
var escapeStringRegexp = require('escape-string-regexp');
68
var groupArray = require('group-array');
@@ -9,9 +11,8 @@ var transform = require('../transform');
911
var tags = require('../tags');
1012
var getFilepath = require('../path');
1113

12-
var PluginError = gutil.PluginError;
13-
var magenta = gutil.colors.magenta;
14-
var cyan = gutil.colors.cyan;
14+
var magenta = colors.magenta;
15+
var cyan = colors.cyan;
1516
var noop = function noop() {};
1617

1718
/**
@@ -284,7 +285,7 @@ function getTagsToInject(files, target, opt) {
284285
}
285286

286287
function log(message) {
287-
gutil.log(magenta(PLUGIN_NAME), message);
288+
fancyLog.info(magenta(PLUGIN_NAME), message);
288289
}
289290

290291
function error(message) {

Diff for: src/inject/inject_test.js

+10-9
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,20 @@ var fs = require('fs');
55
var path = require('path');
66
var es = require('event-stream');
77
var should = require('should');
8-
var gutil = require('gulp-util');
8+
var fancyLog = require('fancy-log');
9+
var Vinyl = require('vinyl');
910
var stripColor = require('strip-color');
1011
var inject = require('../../.');
1112

1213
describe('gulp-inject', function () {
1314
var log;
1415

1516
beforeEach(function () {
16-
log = gutil.log;
17+
log = fancyLog.info;
1718
});
1819

1920
afterEach(function () {
20-
gutil.log = log;
21+
fancyLog.info = log;
2122
});
2223

2324
it('should throw an error when the old api with target as string is used', function () {
@@ -509,7 +510,7 @@ describe('gulp-inject', function () {
509510

510511
it('should not produce log output if quiet option is set', function (done) {
511512
var logOutput = [];
512-
gutil.log = function () {
513+
fancyLog.info = function () {
513514
logOutput.push(arguments);
514515
};
515516

@@ -535,7 +536,7 @@ describe('gulp-inject', function () {
535536

536537
it('should produce log output if quiet option is not set', function (done) {
537538
var logOutput = [];
538-
gutil.log = function () {
539+
fancyLog.info = function () {
539540
logOutput.push(arguments);
540541
};
541542

@@ -561,7 +562,7 @@ describe('gulp-inject', function () {
561562

562563
it('should produce log output only for files actually injected (issue #184)', function (done) {
563564
var logOutput = [];
564-
gutil.log = function (a, b) {
565+
fancyLog.info = function (a, b) {
565566
logOutput.push(a + ' ' + b);
566567
};
567568

@@ -588,7 +589,7 @@ describe('gulp-inject', function () {
588589

589590
it('should produce log output for multiple files actually injected (issue #192)', function (done) {
590591
var logOutput = [];
591-
gutil.log = function (a, b) {
592+
fancyLog.info = function (a, b) {
592593
logOutput.push(a + ' ' + b);
593594
};
594595

@@ -740,7 +741,7 @@ function streamShouldContain(stream, files, done) {
740741

741742
function expectedFile(file) {
742743
var filepath = path.resolve(__dirname, 'expected', file);
743-
return new gutil.File({
744+
return new Vinyl({
744745
path: filepath,
745746
cwd: __dirname,
746747
base: path.resolve(__dirname, 'expected', path.dirname(file)),
@@ -750,7 +751,7 @@ function expectedFile(file) {
750751

751752
function fixture(file, read) {
752753
var filepath = path.resolve(__dirname, 'fixtures', file);
753-
return new gutil.File({
754+
return new Vinyl({
754755
path: filepath,
755756
cwd: __dirname,
756757
base: path.resolve(__dirname, 'fixtures', path.dirname(file)),

Diff for: src/path/path_test.js

+17-17
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
/* eslint-env mocha */
22
'use strict';
33
var path = require('path');
4-
var File = require('gulp-util').File;
4+
var Vinyl = require('vinyl');
55
require('should');
66
var getFilepath = require('./');
77

88
describe('getFilepath', function () {
99
describe('(relative=false)', function () {
1010
it('returns the path relative to the source file\'s cwd', function () {
11-
var source = new File({
11+
var source = new Vinyl({
1212
cwd: __dirname,
1313
path: path.join(__dirname, 'dir', 'file.js'),
1414
base: path.join(__dirname, 'dir')
@@ -19,7 +19,7 @@ describe('getFilepath', function () {
1919
});
2020

2121
it('returns the unixified path relative to the source file\'s cwd', function () {
22-
var source = new File({
22+
var source = new Vinyl({
2323
cwd: 'C:\\a\\folder',
2424
path: 'C:\\a\\folder\\dir\\file.js',
2525
base: 'C:\\a\\folder\\dir'
@@ -32,12 +32,12 @@ describe('getFilepath', function () {
3232

3333
describe('(relative=true)', function () {
3434
it('returns the path relative to the target file\'s directory', function () {
35-
var target = new File({
35+
var target = new Vinyl({
3636
cwd: __dirname,
3737
path: path.join(__dirname, 'dir1', 'index.html'),
3838
base: path.join(__dirname, 'dir1')
3939
});
40-
var source = new File({
40+
var source = new Vinyl({
4141
cwd: __dirname,
4242
path: path.join(__dirname, 'dir2', 'file.js'),
4343
base: path.join(__dirname, 'dir2')
@@ -48,12 +48,12 @@ describe('getFilepath', function () {
4848
});
4949

5050
it('returns the unixified path relative to the source file\'s cwd', function () {
51-
var target = new File({
51+
var target = new Vinyl({
5252
cwd: 'C:\\a\\folder',
5353
path: 'C:\\a\\folder\\dir1\\index.html',
5454
base: 'C:\\a\\folder\\dir1'
5555
});
56-
var source = new File({
56+
var source = new Vinyl({
5757
cwd: 'C:\\a\\folder',
5858
path: 'C:\\a\\folder\\dir2\\file.js',
5959
base: 'C:\\a\\folder\\dir2'
@@ -66,7 +66,7 @@ describe('getFilepath', function () {
6666

6767
describe('(ignorePath)', function () {
6868
it('removes the provided `ignorePath` from the beginning of the path', function () {
69-
var source = new File({
69+
var source = new Vinyl({
7070
cwd: __dirname,
7171
path: path.join(__dirname, 'dir', 'file.js'),
7272
base: path.join(__dirname, 'dir')
@@ -77,7 +77,7 @@ describe('getFilepath', function () {
7777
});
7878

7979
it('removes the provided `ignorePath` even if it both begins and ends in a `/` from the beginning of the path', function () {
80-
var source = new File({
80+
var source = new Vinyl({
8181
cwd: __dirname,
8282
path: path.join(__dirname, 'dir', 'file.js'),
8383
base: path.join(__dirname, 'dir')
@@ -88,7 +88,7 @@ describe('getFilepath', function () {
8888
});
8989

9090
it('removes the provided `ignorePath`s from the beginning of the path', function () {
91-
var source = new File({
91+
var source = new Vinyl({
9292
cwd: __dirname,
9393
path: path.join(__dirname, 'dir', 'file.js'),
9494
base: path.join(__dirname, 'dir')
@@ -99,7 +99,7 @@ describe('getFilepath', function () {
9999
});
100100

101101
it('removes the provided `ignorePath` unixified from the beginning of the path', function () {
102-
var source = new File({
102+
var source = new Vinyl({
103103
cwd: __dirname,
104104
path: path.join(__dirname, 'dir', 'deep', 'file.js'),
105105
base: path.join(__dirname, 'dir', 'deep')
@@ -110,7 +110,7 @@ describe('getFilepath', function () {
110110
});
111111

112112
it('removes the provided `ignorePath` unixified from the beginning of a unixified path', function () {
113-
var source = new File({
113+
var source = new Vinyl({
114114
cwd: 'C:\\a\\folder',
115115
path: 'C:\\a\\folder\\dir\\deep\\file.js',
116116
base: 'C:\\a\\folder\\dir\\deep'
@@ -121,7 +121,7 @@ describe('getFilepath', function () {
121121
});
122122

123123
it('removes the provided `ignorePath` from the beginning of a unixified path', function () {
124-
var source = new File({
124+
var source = new Vinyl({
125125
cwd: 'C:\\a\\folder',
126126
path: 'C:\\a\\folder\\dir\\deep\\file.js',
127127
base: 'C:\\a\\folder\\dir\\deep'
@@ -134,7 +134,7 @@ describe('getFilepath', function () {
134134

135135
describe('(addRootSlash=true)', function () {
136136
it('prepends the path with a `/`', function () {
137-
var source = new File({
137+
var source = new Vinyl({
138138
cwd: __dirname,
139139
path: path.join(__dirname, 'dir', 'file.js'),
140140
base: path.join(__dirname, 'dir')
@@ -147,7 +147,7 @@ describe('getFilepath', function () {
147147

148148
describe('(addPrefix)', function () {
149149
it('prepends the prefix and a `/` to the path', function () {
150-
var source = new File({
150+
var source = new Vinyl({
151151
cwd: __dirname,
152152
path: path.join(__dirname, 'dir', 'file.js'),
153153
base: path.join(__dirname, 'dir')
@@ -158,7 +158,7 @@ describe('getFilepath', function () {
158158
});
159159

160160
it('keeps any leading `/` from the prefix', function () {
161-
var source = new File({
161+
var source = new Vinyl({
162162
cwd: __dirname,
163163
path: path.join(__dirname, 'dir', 'file.js'),
164164
base: path.join(__dirname, 'dir')
@@ -171,7 +171,7 @@ describe('getFilepath', function () {
171171

172172
describe('(addSuffix)', function () {
173173
it('appends the suffix to the path', function () {
174-
var source = new File({
174+
var source = new Vinyl({
175175
cwd: __dirname,
176176
path: path.join(__dirname, 'dir', 'file.js'),
177177
base: path.join(__dirname, 'dir')

Diff for: src/transform/transform_test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
var path = require('path');
44
var fs = require('fs');
55
var should = require('should');
6-
var gutil = require('gulp-util');
6+
var Vinyl = require('vinyl');
77

88
describe('transform', function () {
99
var transform;
@@ -554,7 +554,7 @@ describe('transform', function () {
554554

555555
function fixture(file, read) {
556556
var filepath = path.resolve(__dirname, 'fixtures', file);
557-
return new gutil.File({
557+
return new Vinyl({
558558
path: filepath,
559559
cwd: __dirname,
560560
base: path.resolve(__dirname, 'fixtures', path.dirname(file)),

0 commit comments

Comments
 (0)