gulp-shell
Advanced tools
Comparing version 0.6.3 to 0.6.4
@@ -5,6 +5,3 @@ const gulp = require('gulp') | ||
const paths = { | ||
js: [ | ||
'*.js', | ||
'test/*.js' | ||
] | ||
js: ['*.js', 'test/*.js'] | ||
} | ||
@@ -16,3 +13,7 @@ | ||
gulp.task('coveralls', ['coverage'], shell.task('cat coverage/lcov.info | coveralls')) | ||
gulp.task( | ||
'coveralls', | ||
['coverage'], | ||
shell.task('cat coverage/lcov.info | coveralls') | ||
) | ||
@@ -19,0 +20,0 @@ gulp.task('lint', shell.task('standard ' + paths.js.join(' '))) |
17
index.js
const _ = require('lodash') | ||
const async = require('async') | ||
const gutil = require('gulp-util') | ||
const chalk = require('chalk') | ||
const fancyLog = require('fancy-log') | ||
const path = require('path') | ||
const PluginError = require('plugin-error') | ||
const spawn = require('child_process').spawn | ||
const template = require('lodash.template') | ||
const through = require('through2') | ||
@@ -16,3 +19,3 @@ | ||
if (!Array.isArray(commands)) { | ||
throw new gutil.PluginError(PLUGIN_NAME, 'Missing commands') | ||
throw new PluginError(PLUGIN_NAME, 'Missing commands') | ||
} | ||
@@ -44,6 +47,6 @@ | ||
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)) | ||
} | ||
@@ -53,3 +56,3 @@ | ||
env: options.env, | ||
cwd: gutil.template(options.cwd, context), | ||
cwd: template(options.cwd)(context), | ||
shell: options.shell, | ||
@@ -70,5 +73,5 @@ stdio: options.quiet ? 'ignore' : 'inherit' | ||
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)) | ||
}) | ||
@@ -75,0 +78,0 @@ }, done) |
{ | ||
"name": "gulp-shell", | ||
"version": "0.6.3", | ||
"version": "0.6.4", | ||
"description": "A handy command line interface for gulp", | ||
@@ -37,5 +37,9 @@ "main": "index.js", | ||
"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" | ||
}, | ||
@@ -42,0 +46,0 @@ "engines": { |
@@ -35,6 +35,3 @@ # gulp-shell | ||
```js | ||
gulp.task('shorthand', shell.task([ | ||
'echo hello', | ||
'echo world' | ||
])) | ||
gulp.task('greet', shell.task('echo Hello, World!')) | ||
``` | ||
@@ -41,0 +38,0 @@ |
/* eslint-env mocha */ | ||
const gutil = require('gulp-util') | ||
const expect = require('chai').expect | ||
const join = require('path').join | ||
const expect = require('chai').expect | ||
const Vinyl = require('vinyl') | ||
@@ -10,9 +10,9 @@ const shell = require('..') | ||
function expectToBeOk (stream, done) { | ||
stream | ||
.on('error', done) | ||
.on('data', () => { done() }) | ||
stream.on('error', done).on('data', () => { | ||
done() | ||
}) | ||
} | ||
describe('gulp-shell(commands, options)', () => { | ||
const fakeFile = new gutil.File({ | ||
const fakeFile = new Vinyl({ | ||
cwd: __dirname, | ||
@@ -31,6 +31,6 @@ base: __dirname, | ||
it('passes file through', (done) => { | ||
it('passes file through', done => { | ||
const stream = shell(['true']) | ||
stream.on('data', (file) => { | ||
stream.on('data', file => { | ||
expect(file).to.equal(fakeFile) | ||
@@ -43,6 +43,4 @@ done() | ||
it('executes command after interpolation', (done) => { | ||
const stream = shell([ | ||
`test <%= file.path %> = ${fakeFile.path}` | ||
]) | ||
it('executes command after interpolation', done => { | ||
const stream = shell([`test <%= file.path %> = ${fakeFile.path}`]) | ||
@@ -54,6 +52,7 @@ expectToBeOk(stream, done) | ||
it('prepends `./node_modules/.bin` to `PATH`', (done) => { | ||
const stream = shell([ | ||
`echo $PATH | grep -q "${join(process.cwd(), 'node_modules/.bin')}"` | ||
], {shell: 'bash'}) | ||
it('prepends `./node_modules/.bin` to `PATH`', done => { | ||
const stream = shell( | ||
[`echo $PATH | grep -q "${join(process.cwd(), 'node_modules/.bin')}"`], | ||
{ shell: 'bash' } | ||
) | ||
@@ -66,3 +65,3 @@ expectToBeOk(stream, done) | ||
describe('.task(commands, options)', () => { | ||
it('returns a function which returns a callback', (done) => { | ||
it('returns a function which returns a callback', done => { | ||
const task = shell.task(['echo hello world']) | ||
@@ -78,6 +77,6 @@ | ||
describe('cwd', () => { | ||
it('sets the current working directory when `cwd` is a string', (done) => { | ||
const stream = shell([ | ||
`test $PWD = ${join(__dirname, '../..')}` | ||
], {cwd: '..'}) | ||
it('sets the current working directory when `cwd` is a string', done => { | ||
const stream = shell([`test $PWD = ${join(__dirname, '../..')}`], { | ||
cwd: '..' | ||
}) | ||
@@ -89,6 +88,4 @@ expectToBeOk(stream, done) | ||
it('uses the process current working directory when `cwd` is not passed', (done) => { | ||
const stream = shell([ | ||
`test $PWD = ${join(__dirname, '..')}` | ||
]) | ||
it('uses the process current working directory when `cwd` is not passed', done => { | ||
const stream = shell([`test $PWD = ${join(__dirname, '..')}`]) | ||
@@ -102,6 +99,4 @@ expectToBeOk(stream, done) | ||
describe('shell', () => { | ||
it('changes the shell', (done) => { | ||
const stream = shell([ | ||
'[[ $0 = bash ]]' | ||
], {shell: 'bash'}) | ||
it('changes the shell', done => { | ||
const stream = shell(['[[ $0 = bash ]]'], { shell: 'bash' }) | ||
@@ -115,4 +110,4 @@ expectToBeOk(stream, done) | ||
describe('quiet', () => { | ||
it("won't output anything when `quiet` == true", (done) => { | ||
const stream = shell(['echo cannot see me!'], {quiet: true}) | ||
it("won't output anything when `quiet` == true", done => { | ||
const stream = shell(['echo cannot see me!'], { quiet: true }) | ||
@@ -126,3 +121,3 @@ expectToBeOk(stream, done) | ||
describe('ignoreErrors', () => { | ||
it('emits error by default', (done) => { | ||
it('emits error by default', done => { | ||
const stream = shell(['false']) | ||
@@ -137,4 +132,4 @@ | ||
it("won't emit error when `ignoreErrors` == true", (done) => { | ||
const stream = shell(['false'], {ignoreErrors: true}) | ||
it("won't emit error when `ignoreErrors` == true", done => { | ||
const stream = shell(['false'], { ignoreErrors: true }) | ||
@@ -154,7 +149,7 @@ stream.on('error', () => { | ||
describe('errorMessage', () => { | ||
it('allows for custom messages', (done) => { | ||
it('allows for custom messages', done => { | ||
const errorMessage = 'foo' | ||
const stream = shell(['false'], {errorMessage}) | ||
const stream = shell(['false'], { errorMessage }) | ||
stream.on('error', (error) => { | ||
stream.on('error', error => { | ||
expect(error.message).to.equal(errorMessage) | ||
@@ -167,8 +162,8 @@ done() | ||
it('includes the error object in the error context', (done) => { | ||
it('includes the error object in the error context', done => { | ||
const errorMessage = 'Foo <%= error.code %>' | ||
const expectedMessage = 'Foo 2' | ||
const stream = shell(['exit 2'], {errorMessage}) | ||
const stream = shell(['exit 2'], { errorMessage }) | ||
stream.on('error', (error) => { | ||
stream.on('error', error => { | ||
expect(error.message).to.equal(expectedMessage) | ||
@@ -175,0 +170,0 @@ done() |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13006
8
8
219
125
+ Addedchalk@^2.3.0
+ Addedfancy-log@^1.3.2
+ Addedlodash.template@^4.4.0
+ Addedplugin-error@^0.1.2
+ Addedvinyl@^2.1.0
+ Addedansi-cyan@0.1.1(transitive)
+ Addedansi-red@0.1.1(transitive)
+ Addedansi-styles@3.2.1(transitive)
+ Addedarr-diff@1.1.0(transitive)
+ Addedarr-flatten@1.1.0(transitive)
+ Addedarr-union@2.1.0(transitive)
+ Addedarray-slice@0.2.3(transitive)
+ Addedchalk@2.4.2(transitive)
+ Addedclone@2.1.2(transitive)
+ Addedclone-buffer@1.0.0(transitive)
+ Addedclone-stats@1.0.0(transitive)
+ Addedcloneable-readable@1.1.3(transitive)
+ Addedcolor-convert@1.9.3(transitive)
+ Addedcolor-name@1.1.3(transitive)
+ Addedextend-shallow@1.1.4(transitive)
+ Addedhas-flag@3.0.0(transitive)
+ Addedkind-of@1.1.0(transitive)
+ Addedlodash.template@4.5.0(transitive)
+ Addedlodash.templatesettings@4.2.0(transitive)
+ Addedplugin-error@0.1.2(transitive)
+ Addedremove-trailing-separator@1.1.0(transitive)
+ Addedreplace-ext@1.0.1(transitive)
+ Addedsupports-color@5.5.0(transitive)
+ Addedvinyl@2.2.1(transitive)
- Removedgulp-util@^3.0.8
- Removedansi-regex@2.1.1(transitive)
- Removedansi-styles@2.2.1(transitive)
- Removedarray-differ@1.0.0(transitive)
- Removedarray-uniq@1.0.3(transitive)
- Removedbeeper@1.1.1(transitive)
- Removedchalk@1.1.3(transitive)
- Removedclone@1.0.4(transitive)
- Removedclone-stats@0.0.1(transitive)
- Removeddateformat@2.2.0(transitive)
- Removedduplexer2@0.0.2(transitive)
- Removedglogg@1.0.2(transitive)
- Removedgulp-util@3.0.8(transitive)
- Removedgulplog@1.0.0(transitive)
- Removedhas-ansi@2.0.0(transitive)
- Removedhas-gulplog@0.1.0(transitive)
- Removedisarray@0.0.1(transitive)
- Removedlodash._basecopy@3.0.1(transitive)
- Removedlodash._basetostring@3.0.1(transitive)
- Removedlodash._basevalues@3.0.0(transitive)
- Removedlodash._getnative@3.9.1(transitive)
- Removedlodash._isiterateecall@3.0.9(transitive)
- Removedlodash._reescape@3.0.0(transitive)
- Removedlodash._reevaluate@3.0.0(transitive)
- Removedlodash._root@3.0.1(transitive)
- Removedlodash.escape@3.2.0(transitive)
- Removedlodash.isarguments@3.1.0(transitive)
- Removedlodash.isarray@3.0.4(transitive)
- Removedlodash.keys@3.1.2(transitive)
- Removedlodash.restparam@3.6.1(transitive)
- Removedlodash.template@3.6.2(transitive)
- Removedlodash.templatesettings@3.1.1(transitive)
- Removedminimist@1.2.8(transitive)
- Removedmultipipe@0.1.2(transitive)
- Removedobject-assign@3.0.0(transitive)
- Removedreadable-stream@1.1.14(transitive)
- Removedreplace-ext@0.0.1(transitive)
- Removedsparkles@1.0.1(transitive)
- Removedstring_decoder@0.10.31(transitive)
- Removedstrip-ansi@3.0.1(transitive)
- Removedsupports-color@2.0.0(transitive)
- Removedvinyl@0.5.3(transitive)