Skip to content

Commit 87d25e8

Browse files
committed
Replace gulp-util to plugin-error and some upgrade
gulp-util is deprecated and replaced to plugin-error package. See more on this page: https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5
1 parent 90ae4cb commit 87d25e8

File tree

3 files changed

+23
-21
lines changed

3 files changed

+23
-21
lines changed

index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'use strict';
2-
var gutil = require('gulp-util');
2+
var pluginError = require('plugin-error');
33
var through = require('through2');
44
var iconv = require('iconv-lite');
55

@@ -10,7 +10,7 @@ module.exports = function (options) {
1010
options = options || {};
1111

1212
if (!options.from && !options.to) {
13-
throw new gutil.PluginError('gulp-convert-encoding', 'At least one of `from` or `to` required');
13+
throw new pluginError('gulp-convert-encoding', 'At least one of `from` or `to` required');
1414
}
1515

1616
options.from = options.from || UTF8;
@@ -33,7 +33,7 @@ module.exports = function (options) {
3333
.pipe(iconv.encodeStream(options.to, options.iconv.encode));
3434
this.push(file);
3535
} catch (err) {
36-
this.emit('error', new gutil.PluginError('gulp-convert-encoding', err));
36+
this.emit('error', new pluginError('gulp-convert-encoding', err));
3737
}
3838
}
3939

@@ -43,7 +43,7 @@ module.exports = function (options) {
4343
file.contents = iconv.encode(content, options.to, options.iconv.encode);
4444
this.push(file);
4545
} catch (err) {
46-
this.emit('error', new gutil.PluginError('gulp-convert-encoding', err));
46+
this.emit('error', new pluginError('gulp-convert-encoding', err));
4747
}
4848
}
4949

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,17 @@
3030
"charset"
3131
],
3232
"dependencies": {
33-
"gulp-util": "^3.0.6",
3433
"iconv-lite": "^0.4.9",
34+
"plugin-error": "^1.0.1",
3535
"through2": "^2.0.0"
3636
},
3737
"devDependencies": {
38-
"coveralls": "^2.11.2",
38+
"coveralls": "^3.0.2",
3939
"event-stream": "^3.1.7",
40-
"istanbul": "^0.3.5",
40+
"istanbul": "^0.4.5",
4141
"mocha": "*",
4242
"mocha-lcov-reporter": "0.0.2",
43-
"should": "^7.0.2"
43+
"should": "^7.0.2",
44+
"vinyl": "^2.2.0"
4445
}
4546
}

test.js

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
'use strict';
22
var should = require('should');
33
var assert = require('assert');
4-
var gutil = require('gulp-util');
4+
var Vinyl = require('vinyl');
55
var iconv = require('iconv-lite');
6+
var mystream = require('stream');
67
var es = require('event-stream');
78
var convertEncoding = require('./');
89

@@ -23,7 +24,7 @@ describe('gulp-convert-encoding', function() {
2324
(function(){
2425
var stream = convertEncoding({to: LATIN1});
2526

26-
stream.write(new gutil.File({
27+
stream.write(new Vinyl({
2728
base: path.join(__dirname, './fixtures/'),
2829
cwd: __dirname,
2930
path: path.join(__dirname + './fixtures/1x1.png')
@@ -45,7 +46,7 @@ describe('gulp-convert-encoding', function() {
4546
cb();
4647
});
4748

48-
stream.write(new gutil.File({
49+
stream.write(new Vinyl({
4950
base: __dirname,
5051
path: __dirname + '/file.txt',
5152
contents: null
@@ -66,10 +67,10 @@ describe('gulp-convert-encoding', function() {
6667

6768
stream.on('end', cb);
6869

69-
stream.write(new gutil.File({
70+
stream.write(new Vinyl({
7071
base: __dirname,
7172
path: __dirname + '/file.txt',
72-
contents: new Buffer(testString)
73+
contents: Buffer.from(testString)
7374
}));
7475

7576
stream.end();
@@ -86,10 +87,10 @@ describe('gulp-convert-encoding', function() {
8687

8788
stream.on('end', cb);
8889

89-
stream.write(new gutil.File({
90+
stream.write(new Vinyl({
9091
base: __dirname,
9192
path: __dirname + '/file.txt',
92-
contents: new Buffer([0xe4, 0xf6, 0xfc, 0xdf])
93+
contents: Buffer.from([0xe4, 0xf6, 0xfc, 0xdf])
9394
}));
9495

9596
stream.end();
@@ -106,16 +107,16 @@ describe('gulp-convert-encoding', function() {
106107

107108
// buffer the contents
108109
file.contents.pipe(es.wait(function(err, data) {
109-
assert.equal(iconv.decode(new Buffer(data), LATIN1), testString);
110+
assert.equal(iconv.decode(Buffer.from(data), LATIN1), testString);
110111
}));
111112
});
112113

113114
stream.on('end', cb);
114115

115-
stream.write(new gutil.File({
116+
stream.write(new Vinyl({
116117
base: __dirname,
117118
path: __dirname + '/file.txt',
118-
contents: es.readArray([testString])
119+
contents: new mystream.Readable({objectMode: true}).wrap(es.readArray([testString]))
119120
}));
120121

121122
stream.end();
@@ -130,16 +131,16 @@ describe('gulp-convert-encoding', function() {
130131

131132
// buffer the contents
132133
file.contents.pipe(es.wait(function(err, data) {
133-
assert.equal(iconv.decode(new Buffer(data), UTF8), testString);
134+
assert.equal(iconv.decode(Buffer.from(data), UTF8), testString);
134135
}));
135136
});
136137

137138
stream.on('end', cb);
138139

139-
stream.write(new gutil.File({
140+
stream.write(new Vinyl({
140141
base: __dirname,
141142
path: __dirname + '/file.txt',
142-
contents: es.readArray([new Buffer([0xe4, 0xf6, 0xfc, 0xdf])])
143+
contents: new mystream.Readable({objectMode: true}).wrap(es.readArray([Buffer.from([0xe4, 0xf6, 0xfc, 0xdf])]))
143144
}));
144145

145146
stream.end();

0 commit comments

Comments
 (0)