Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop dependency on deprecated gulp-util #95

Merged
merged 1 commit into from
Dec 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
const _ = require('lodash')
const async = require('async')
const gutil = require('gulp-util')
const PluginError = require('plugin-error')
const fancyLog = require('fancy-log')
const template = require('lodash.template')
const chalk = require('chalk')
const path = require('path')
const spawn = require('child_process').spawn
const through = require('through2')
Expand All @@ -13,7 +16,7 @@ function normalizeCommands (commands) {
}

if (!Array.isArray(commands)) {
throw new gutil.PluginError(PLUGIN_NAME, 'Missing commands')
throw new PluginError(PLUGIN_NAME, 'Missing commands')
}

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

if (options.verbose) {
gutil.log(gutil.colors.cyan(command))
fancyLog(chalk.cyan(command))
}

const child = spawn(command, {
env: options.env,
cwd: gutil.template(options.cwd, context),
cwd: template(options.cwd)(context),
shell: options.shell,
stdio: options.quiet ? 'ignore' : 'inherit'
})
Expand All @@ -64,9 +67,9 @@ function runCommands (commands, options, file, done) {
error: {code}
}, options.templateData)

const message = gutil.template(options.errorMessage, context)
const message = template(options.errorMessage)(context)

done(new gutil.PluginError(PLUGIN_NAME, message))
done(new PluginError(PLUGIN_NAME, message))
})
}, done)
}
Expand Down
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,13 @@
},
"dependencies": {
"async": "^2.1.5",
"gulp-util": "^3.0.8",
"chalk": "^2.3.0",
"fancy-log": "^1.3.2",
"lodash": "^4.17.4",
"through2": "^2.0.3"
"lodash.template": "^4.4.0",
"plugin-error": "^0.1.2",
"through2": "^2.0.3",
"vinyl": "^2.1.0"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vinyl should be in the devDependencies. It is only used for the tests.
Please update it: it is important to avoid unnecessary dependencies.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, that's true. I created another PR for that #96

},
"engines": {
"node": ">=4.8.0 <5.0.0 || >=5.7.0"
Expand Down
4 changes: 2 additions & 2 deletions test/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-env mocha */

const gutil = require('gulp-util')
const Vinyl = require('vinyl')
const join = require('path').join
const expect = require('chai').expect

Expand All @@ -13,7 +13,7 @@ function expectToBeOk (stream, done) {
}

describe('gulp-shell(commands, options)', () => {
const fakeFile = new gutil.File({
const fakeFile = new Vinyl({
cwd: __dirname,
base: __dirname,
path: join(__dirname, 'test-file')
Expand Down