Skip to content

Commit 71f6d26

Browse files
authored
Merge pull request #95 from ohbarye/remove-gulp-util
Drop dependency on deprecated gulp-util
2 parents bc95669 + b81e940 commit 71f6d26

File tree

3 files changed

+18
-11
lines changed

3 files changed

+18
-11
lines changed

index.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
const _ = require('lodash')
22
const async = require('async')
3-
const gutil = require('gulp-util')
3+
const PluginError = require('plugin-error')
4+
const fancyLog = require('fancy-log')
5+
const template = require('lodash.template')
6+
const chalk = require('chalk')
47
const path = require('path')
58
const spawn = require('child_process').spawn
69
const through = require('through2')
@@ -13,7 +16,7 @@ function normalizeCommands (commands) {
1316
}
1417

1518
if (!Array.isArray(commands)) {
16-
throw new gutil.PluginError(PLUGIN_NAME, 'Missing commands')
19+
throw new PluginError(PLUGIN_NAME, 'Missing commands')
1720
}
1821

1922
return commands
@@ -40,15 +43,15 @@ function normalizeOptions (options) {
4043
function runCommands (commands, options, file, done) {
4144
async.eachSeries(commands, (command, done) => {
4245
const context = _.extend({file}, options.templateData)
43-
command = gutil.template(command, context)
46+
command = template(command)(context)
4447

4548
if (options.verbose) {
46-
gutil.log(gutil.colors.cyan(command))
49+
fancyLog(chalk.cyan(command))
4750
}
4851

4952
const child = spawn(command, {
5053
env: options.env,
51-
cwd: gutil.template(options.cwd, context),
54+
cwd: template(options.cwd)(context),
5255
shell: options.shell,
5356
stdio: options.quiet ? 'ignore' : 'inherit'
5457
})
@@ -64,9 +67,9 @@ function runCommands (commands, options, file, done) {
6467
error: {code}
6568
}, options.templateData)
6669

67-
const message = gutil.template(options.errorMessage, context)
70+
const message = template(options.errorMessage)(context)
6871

69-
done(new gutil.PluginError(PLUGIN_NAME, message))
72+
done(new PluginError(PLUGIN_NAME, message))
7073
})
7174
}, done)
7275
}

package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,13 @@
3434
},
3535
"dependencies": {
3636
"async": "^2.1.5",
37-
"gulp-util": "^3.0.8",
37+
"chalk": "^2.3.0",
38+
"fancy-log": "^1.3.2",
3839
"lodash": "^4.17.4",
39-
"through2": "^2.0.3"
40+
"lodash.template": "^4.4.0",
41+
"plugin-error": "^0.1.2",
42+
"through2": "^2.0.3",
43+
"vinyl": "^2.1.0"
4044
},
4145
"engines": {
4246
"node": ">=4.8.0 <5.0.0 || >=5.7.0"

test/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-env mocha */
22

3-
const gutil = require('gulp-util')
3+
const Vinyl = require('vinyl')
44
const join = require('path').join
55
const expect = require('chai').expect
66

@@ -13,7 +13,7 @@ function expectToBeOk (stream, done) {
1313
}
1414

1515
describe('gulp-shell(commands, options)', () => {
16-
const fakeFile = new gutil.File({
16+
const fakeFile = new Vinyl({
1717
cwd: __dirname,
1818
base: __dirname,
1919
path: join(__dirname, 'test-file')

0 commit comments

Comments
 (0)