grunt-shell
Advanced tools
Comparing version 1.3.1 to 2.0.0
{ | ||
"name": "grunt-shell", | ||
"version": "1.3.1", | ||
"version": "2.0.0", | ||
"description": "Run shell commands", | ||
@@ -13,3 +13,3 @@ "license": "MIT", | ||
"engines": { | ||
"node": ">=0.10.0" | ||
"node": ">=4" | ||
}, | ||
@@ -35,4 +35,3 @@ "scripts": { | ||
"chalk": "^1.0.0", | ||
"npm-run-path": "^1.0.0", | ||
"object-assign": "^4.0.0" | ||
"npm-run-path": "^2.0.0" | ||
}, | ||
@@ -46,3 +45,6 @@ "devDependencies": { | ||
"grunt": ">=0.4.0" | ||
}, | ||
"xo": { | ||
"esnext": true | ||
} | ||
} |
@@ -186,3 +186,3 @@ # grunt-shell [![Build Status](https://travis-ci.org/sindresorhus/grunt-shell.svg?branch=master)](https://travis-ci.org/sindresorhus/grunt-shell) | ||
*Required*<br> | ||
Type: `String` `Function` | ||
Type: `string` `Function` | ||
@@ -197,3 +197,3 @@ Command to run or a function which returns the command. Supports underscore templates. | ||
Type: `Boolean`<br> | ||
Type: `boolean`<br> | ||
Default: `true` | ||
@@ -205,3 +205,3 @@ | ||
Type: `Boolean`<br> | ||
Type: `boolean`<br> | ||
Default: `true` | ||
@@ -213,3 +213,3 @@ | ||
Type: `Boolean`<br> | ||
Type: `boolean`<br> | ||
Default: `true` | ||
@@ -221,3 +221,3 @@ | ||
Type: `Boolean`<br> | ||
Type: `boolean`<br> | ||
Default: `true` | ||
@@ -229,3 +229,3 @@ | ||
Type: `Boolean`<br> | ||
Type: `boolean`<br> | ||
Default: `false` | ||
@@ -245,6 +245,6 @@ | ||
Type: `Boolean`<br> | ||
Default: `false` | ||
Type: `boolean`<br> | ||
Default: `true` | ||
Execute local binaries by name like [npm run-script](http://blog.keithcirkel.co.uk/how-to-use-npm-as-a-build-tool/). | ||
Execute local binaries by name like [`$ npm run-script`](http://blog.keithcirkel.co.uk/how-to-use-npm-as-a-build-tool/). | ||
@@ -255,11 +255,11 @@ ### execOptions | ||
Specify some options to be passed to the [.exec()](http://nodejs.org/api/child_process.html#child_process_child_process_exec_command_options_callback) method: | ||
Specify some options to be passed to the [.exec()](https://nodejs.org/api/child_process.html#child_process_child_process_exec_command_options_callback) method: | ||
- `cwd` String *Current working directory of the child process* | ||
- `cwd` string *Current working directory of the child process* | ||
- `env` Object *Environment key-value pairs* | ||
- `setsid` Boolean | ||
- `encoding` String *(Default: 'utf8')* | ||
- `timeout` Number *(Default: 0)* | ||
- `maxBuffer` Number *(Default: 200\*1024)* | ||
- `killSignal` String *(Default: 'SIGTERM')* | ||
- `setsid` boolean | ||
- `encoding` string *(Default: `'utf8'`)* | ||
- `timeout` number *(Default: `0`)* | ||
- `maxBuffer` number *(Default: `1000 * 1000 * 10` → 10 MB)* | ||
- `killSignal` string *(Default: `'SIGTERM'`)* | ||
@@ -266,0 +266,0 @@ |
'use strict'; | ||
var exec = require('child_process').exec; | ||
var chalk = require('chalk'); | ||
var npmRunPath = require('npm-run-path'); | ||
var objectAssign = require('object-assign'); | ||
const exec = require('child_process').exec; | ||
const chalk = require('chalk'); | ||
const npmRunPath = require('npm-run-path'); | ||
module.exports = function (grunt) { | ||
const TEN_MEGABYTES = 1000 * 1000 * 10; | ||
module.exports = grunt => { | ||
grunt.registerMultiTask('shell', 'Run shell commands', function () { | ||
var cb = this.async(); | ||
var opts = this.options({ | ||
const cb = this.async(); | ||
const opts = this.options({ | ||
stdout: true, | ||
@@ -16,3 +17,3 @@ stderr: true, | ||
stdinRawMode: false, | ||
preferLocal: false, | ||
preferLocal: true, | ||
execOptions: { | ||
@@ -23,3 +24,3 @@ env: null | ||
var cmd = typeof this.data === 'string' ? this.data : this.data.command; | ||
let cmd = typeof this.data === 'string' ? this.data : this.data.command; | ||
@@ -30,10 +31,13 @@ if (cmd === undefined) { | ||
// increase max buffer | ||
opts.execOptions = Object.assign({}, opts.execOptions); | ||
opts.execOptions.maxBuffer = opts.execOptions.maxBuffer || TEN_MEGABYTES; | ||
cmd = grunt.template.process(typeof cmd === 'function' ? cmd.apply(grunt, arguments) : cmd); | ||
if (opts.preferLocal === true) { | ||
opts.execOptions.env = opts.execOptions.env || objectAssign({}, process.env); | ||
opts.execOptions.env.PATH = npmRunPath({path: opts.execOptions.env.PATH}); | ||
opts.execOptions.env = npmRunPath.env({env: opts.execOptions.env || process.env}); | ||
} | ||
var cp = exec(cmd, opts.execOptions, function (err, stdout, stderr) { | ||
const cp = exec(cmd, opts.execOptions, (err, stdout, stderr) => { | ||
if (typeof opts.callback === 'function') { | ||
@@ -47,7 +51,7 @@ opts.callback.call(this, err, stdout, stderr, cb); | ||
} | ||
}.bind(this)); | ||
}); | ||
var captureOutput = function (child, output) { | ||
const captureOutput = (child, output) => { | ||
if (grunt.option('color') === false) { | ||
child.on('data', function (data) { | ||
child.on('data', data => { | ||
output.write(chalk.stripColor(data)); | ||
@@ -54,0 +58,0 @@ }); |
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
8593
3
66
+ Addednpm-run-path@2.0.2(transitive)
+ Addedpath-key@2.0.1(transitive)
- Removedobject-assign@^4.0.0
- Removednpm-run-path@1.0.0(transitive)
- Removedobject-assign@4.1.1(transitive)
- Removedpath-key@1.0.0(transitive)
Updatednpm-run-path@^2.0.0