Skip to content

Commit 6f15b51

Browse files
committed
Drop dependency on gulp-util
because it's deprecated https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5
1 parent 3a1d0df commit 6f15b51

File tree

3 files changed

+35
-30
lines changed

3 files changed

+35
-30
lines changed

index.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
var Stream = require('stream')
22
var postcss = require('postcss')
33
var applySourceMap = require('vinyl-sourcemaps-apply')
4-
var gutil = require('gulp-util')
4+
var fancyLog = require('fancy-log')
5+
var PluginError = require('plugin-error')
56
var path = require('path')
67

78

@@ -39,7 +40,7 @@ module.exports = withConfigLoader(function (loadConfig) {
3940
if (configOpts.hasOwnProperty(opt) && !isProtected[opt]) {
4041
options[opt] = configOpts[opt]
4142
} else {
42-
gutil.log(
43+
fancyLog.info(
4344
'gulp-postcss:',
4445
file.relative + '\nCannot override ' + opt +
4546
' option, because it is required by gulp-sourcemaps'
@@ -68,7 +69,7 @@ module.exports = withConfigLoader(function (loadConfig) {
6869
}
6970

7071
if (warnings) {
71-
gutil.log('gulp-postcss:', file.relative + '\n' + warnings)
72+
fancyLog.info('gulp-postcss:', file.relative + '\n' + warnings)
7273
}
7374

7475
setImmediate(function () {
@@ -89,7 +90,7 @@ module.exports = withConfigLoader(function (loadConfig) {
8990
// Prevent stream’s unhandled exception from
9091
// being suppressed by Promise
9192
setImmediate(function () {
92-
cb(new gutil.PluginError('gulp-postcss', error, errorOptions))
93+
cb(new PluginError('gulp-postcss', error, errorOptions))
9394
})
9495
}
9596

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@
3838
},
3939
"homepage": "https://github.com/postcss/gulp-postcss",
4040
"dependencies": {
41-
"gulp-util": "^3.0.8",
41+
"fancy-log": "^1.3.2",
42+
"plugin-error": "^0.1.2",
4243
"postcss": "^6.0.0",
4344
"postcss-load-config": "^1.2.0",
4445
"vinyl-sourcemaps-apply": "^0.2.1"
@@ -50,6 +51,7 @@
5051
"mocha": "^3.4.2",
5152
"nyc": "^11.0.3",
5253
"proxyquire": "^1.8.0",
53-
"sinon": "^2.3.5"
54+
"sinon": "^2.3.5",
55+
"vinyl": "^2.1.0"
5456
}
5557
}

test.js

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
/* eslint max-len: ["off"] */
33

44
var assert = require('assert')
5-
var gutil = require('gulp-util')
5+
var Vinyl = require('vinyl')
6+
var fancyLog = require('fancy-log')
7+
var PluginError = require('plugin-error')
68
var sourceMaps = require('gulp-sourcemaps')
79
var postcss = require('./index')
810
var proxyquire = require('proxyquire')
@@ -38,7 +40,7 @@ it('should transform css with multiple processors', function (cb) {
3840
cb()
3941
})
4042

41-
stream.write(new gutil.File({
43+
stream.write(new Vinyl({
4244
contents: new Buffer('a { color: black }')
4345
}))
4446

@@ -61,7 +63,7 @@ it('should not transform css with out any processor', function (cb) {
6163
cb()
6264
})
6365

64-
stream.write(new gutil.File({
66+
stream.write(new Vinyl({
6567
contents: new Buffer(css)
6668
}))
6769

@@ -74,7 +76,7 @@ it('should correctly wrap postcss errors', function (cb) {
7476
var stream = postcss([ doubler ])
7577

7678
stream.on('error', function (err) {
77-
assert.ok(err instanceof gutil.PluginError)
79+
assert.ok(err instanceof PluginError)
7880
assert.equal(err.plugin, 'gulp-postcss')
7981
assert.equal(err.column, 1)
8082
assert.equal(err.lineNumber, 1)
@@ -86,7 +88,7 @@ it('should correctly wrap postcss errors', function (cb) {
8688
cb()
8789
})
8890

89-
stream.write(new gutil.File({
91+
stream.write(new Vinyl({
9092
contents: new Buffer('a {'),
9193
path: path.resolve('testpath')
9294
}))
@@ -100,7 +102,7 @@ it('should respond with error on stream files', function (cb) {
100102
var stream = postcss([ doubler ])
101103

102104
stream.on('error', function (err) {
103-
assert.ok(err instanceof gutil.PluginError)
105+
assert.ok(err instanceof PluginError)
104106
assert.equal(err.plugin, 'gulp-postcss')
105107
assert.equal(err.showStack, true)
106108
assert.equal(err.message, 'Streams are not supported!')
@@ -138,7 +140,7 @@ it('should generate source maps', function (cb) {
138140
cb()
139141
})
140142

141-
init.write(new gutil.File({
143+
init.write(new Vinyl({
142144
base: __dirname,
143145
path: __dirname + '/fixture.css',
144146
contents: new Buffer('a { color: black }')
@@ -164,7 +166,7 @@ it('should correctly generate relative source map', function (cb) {
164166
cb()
165167
})
166168

167-
init.write(new gutil.File({
169+
init.write(new Vinyl({
168170
base: __dirname + '/src',
169171
path: __dirname + '/src/fixture.css',
170172
contents: new Buffer('a { color: black }')
@@ -238,7 +240,7 @@ describe('PostCSS Guidelines', function () {
238240
cb()
239241
})
240242

241-
stream.write(new gutil.File({
243+
stream.write(new Vinyl({
242244
contents: new Buffer('a {}'),
243245
path: cssPath
244246
}))
@@ -262,7 +264,7 @@ describe('PostCSS Guidelines', function () {
262264
cb()
263265
})
264266

265-
stream.write(new gutil.File({
267+
stream.write(new Vinyl({
266268
contents: new Buffer('a {}')
267269
}))
268270

@@ -273,7 +275,7 @@ describe('PostCSS Guidelines', function () {
273275
it('should take plugins and options from callback', function (cb) {
274276

275277
var cssPath = __dirname + '/fixture.css'
276-
var file = new gutil.File({
278+
var file = new Vinyl({
277279
contents: new Buffer('a {}'),
278280
path: cssPath
279281
})
@@ -305,7 +307,7 @@ describe('PostCSS Guidelines', function () {
305307
it('should take plugins and options from postcss-load-config', function (cb) {
306308

307309
var cssPath = __dirname + '/fixture.css'
308-
var file = new gutil.File({
310+
var file = new Vinyl({
309311
contents: new Buffer('a {}'),
310312
path: cssPath
311313
})
@@ -352,7 +354,7 @@ describe('PostCSS Guidelines', function () {
352354
assert.deepEqual(postcssLoadConfigStub.getCall(0).args[1], __dirname)
353355
cb()
354356
})
355-
stream.end(new gutil.File({
357+
stream.end(new Vinyl({
356358
contents: new Buffer('a {}'),
357359
path: cssPath
358360
}))
@@ -372,7 +374,7 @@ describe('PostCSS Guidelines', function () {
372374
assert.deepEqual(postcssLoadConfigStub.getCall(0).args[1], '/absolute/path')
373375
cb()
374376
})
375-
stream.end(new gutil.File({
377+
stream.end(new Vinyl({
376378
contents: new Buffer('a {}'),
377379
path: cssPath
378380
}))
@@ -392,7 +394,7 @@ describe('PostCSS Guidelines', function () {
392394
assert.deepEqual(postcssLoadConfigStub.getCall(0).args[1], path.join(__dirname, 'relative/path'))
393395
cb()
394396
})
395-
stream.end(new gutil.File({
397+
stream.end(new Vinyl({
396398
contents: new Buffer('a {}'),
397399
path: cssPath,
398400
base: __dirname
@@ -417,19 +419,19 @@ describe('PostCSS Guidelines', function () {
417419
}
418420
}))
419421

420-
sandbox.stub(gutil, 'log')
422+
sandbox.stub(fancyLog, 'info')
421423

422424
stream.on('data', function () {
423425
assert.deepEqual(postcssStub.process.getCall(0).args[1].from, cssPath)
424426
assert.deepEqual(postcssStub.process.getCall(0).args[1].map, { annotation: false })
425-
var firstMessage = gutil.log.getCall(0).args[1]
426-
var secondMessage = gutil.log.getCall(1).args[1]
427+
var firstMessage = fancyLog.info.getCall(0).args[1]
428+
var secondMessage = fancyLog.info.getCall(1).args[1]
427429
assert(firstMessage, '/fixture.css\nCannot override from option, because it is required by gulp-sourcemaps')
428430
assert(secondMessage, '/fixture.css\nCannot override map option, because it is required by gulp-sourcemaps')
429431
cb()
430432
})
431433

432-
var file = new gutil.File({
434+
var file = new Vinyl({
433435
contents: new Buffer('a {}'),
434436
path: cssPath
435437
})
@@ -450,7 +452,7 @@ describe('PostCSS Guidelines', function () {
450452
cb()
451453
})
452454

453-
stream.write(new gutil.File({
455+
stream.write(new Vinyl({
454456
contents: new Buffer('a {}')
455457
}))
456458

@@ -469,7 +471,7 @@ describe('PostCSS Guidelines', function () {
469471
}
470472
}
471473

472-
sandbox.stub(gutil, 'log')
474+
sandbox.stub(fancyLog, 'info')
473475
postcssStub.process.returns(Promise.resolve({
474476
css: '',
475477
warnings: function () {
@@ -478,11 +480,11 @@ describe('PostCSS Guidelines', function () {
478480
}))
479481

480482
stream.on('data', function () {
481-
assert(gutil.log.calledWith('gulp-postcss:', 'src' + path.sep + 'fixture.css\nmsg1\nmsg2'))
483+
assert(fancyLog.info.calledWith('gulp-postcss:', 'src' + path.sep + 'fixture.css\nmsg1\nmsg2'))
482484
cb()
483485
})
484486

485-
stream.write(new gutil.File({
487+
stream.write(new Vinyl({
486488
contents: new Buffer('a {}'),
487489
path: cssPath
488490
}))
@@ -517,7 +519,7 @@ describe('PostCSS Guidelines', function () {
517519
cb()
518520
})
519521

520-
stream.write(new gutil.File({
522+
stream.write(new Vinyl({
521523
contents: new Buffer('a {}'),
522524
path: cssPath
523525
}))

0 commit comments

Comments
 (0)