Skip to content

Commit 62cdda5

Browse files
committed
Require Node.js >=6 and Grunt >=1
1 parent 86680b4 commit 62cdda5

File tree

10 files changed

+97
-112
lines changed

10 files changed

+97
-112
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ charset = utf-8
77
trim_trailing_whitespace = true
88
insert_final_newline = true
99

10-
[{package.json,*.yml}]
10+
[*.yml]
1111
indent_style = space
1212
indent_size = 2

.gitattributes

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
* text=auto
2-
*.js text eol=lf
1+
* text=auto eol=lf

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
node_modules
2+
yarn.lock

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package-lock=false

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
sudo: false
21
language: node_js
32
node_js:
3+
- '10'
4+
- '8'
45
- '6'
5-
- '4'

gruntfile.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,30 @@
11
'use strict';
2+
23
module.exports = grunt => {
34
let checkCounter = 0;
45

56
function check(substring) {
67
checkCounter++;
78

8-
return (err, stdout, stderr, cb) => {
9-
if (err) {
10-
grunt.fatal(`Command failed: ${err}`);
9+
return (error, stdout, stderr, callback) => {
10+
if (error) {
11+
grunt.fatal(`Command failed: ${error}`);
1112
}
1213

1314
if (!stdout.includes(substring)) {
1415
grunt.fatal(`Expected substring not found: ${substring}`);
1516
}
1617

1718
checkCounter--;
18-
cb();
19+
callback();
1920
};
2021
}
2122

2223
let path = null;
2324

24-
function pathCallback(err, stdout, stderr, cb) {
25-
if (err) {
26-
grunt.fatal(`Command failed: ${err}`);
25+
function pathCallback(error, stdout, stderr, callback) {
26+
if (error) {
27+
grunt.fatal(`Command failed: ${error}`);
2728
}
2829

2930
if (path === null) {
@@ -32,7 +33,7 @@ module.exports = grunt => {
3233
grunt.fatal('Path shouldn\'t have changed!');
3334
}
3435

35-
cb();
36+
callback();
3637
}
3738

3839
grunt.initConfig({

license

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,9 @@
1-
The MIT License (MIT)
1+
MIT License
22

33
Copyright (c) Sindre Sorhus <[email protected]> (sindresorhus.com)
44

5-
Permission is hereby granted, free of charge, to any person obtaining a copy
6-
of this software and associated documentation files (the "Software"), to deal
7-
in the Software without restriction, including without limitation the rights
8-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9-
copies of the Software, and to permit persons to whom the Software is
10-
furnished to do so, subject to the following conditions:
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
116

12-
The above copyright notice and this permission notice shall be included in
13-
all copies or substantial portions of the Software.
7+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
148

15-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21-
THE SOFTWARE.
9+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

package.json

Lines changed: 42 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,44 @@
11
{
2-
"name": "grunt-shell",
3-
"version": "2.1.0",
4-
"description": "Run shell commands",
5-
"license": "MIT",
6-
"repository": "sindresorhus/grunt-shell",
7-
"author": {
8-
"name": "Sindre Sorhus",
9-
"email": "[email protected]",
10-
"url": "sindresorhus.com"
11-
},
12-
"engines": {
13-
"node": ">=4"
14-
},
15-
"scripts": {
16-
"test": "xo && grunt"
17-
},
18-
"files": [
19-
"tasks"
20-
],
21-
"keywords": [
22-
"gruntplugin",
23-
"shell",
24-
"command",
25-
"cmd",
26-
"exec",
27-
"spawn",
28-
"child",
29-
"process",
30-
"cli"
31-
],
32-
"dependencies": {
33-
"chalk": "^1.0.0",
34-
"npm-run-path": "^2.0.0"
35-
},
36-
"devDependencies": {
37-
"grunt": "^1.0.1",
38-
"grunt-cli": "^1.2.0",
39-
"xo": "0.20.3"
40-
},
41-
"peerDependencies": {
42-
"grunt": ">=0.4.0"
43-
},
44-
"xo": {
45-
"esnext": true
46-
}
2+
"name": "grunt-shell",
3+
"version": "2.1.0",
4+
"description": "Run shell commands",
5+
"license": "MIT",
6+
"repository": "sindresorhus/grunt-shell",
7+
"author": {
8+
"name": "Sindre Sorhus",
9+
"email": "[email protected]",
10+
"url": "sindresorhus.com"
11+
},
12+
"engines": {
13+
"node": ">=6"
14+
},
15+
"scripts": {
16+
"test": "xo && grunt"
17+
},
18+
"files": [
19+
"tasks"
20+
],
21+
"keywords": [
22+
"gruntplugin",
23+
"shell",
24+
"command",
25+
"cmd",
26+
"exec",
27+
"spawn",
28+
"child",
29+
"process",
30+
"cli"
31+
],
32+
"dependencies": {
33+
"chalk": "^2.4.1",
34+
"npm-run-path": "^2.0.0"
35+
},
36+
"devDependencies": {
37+
"grunt": "^1.0.1",
38+
"grunt-cli": "^1.2.0",
39+
"xo": "^0.23.0"
40+
},
41+
"peerDependencies": {
42+
"grunt": ">=1"
43+
}
4744
}

readme.md

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,26 @@
22

33
> Run shell commands
44
5-
A good way to interact with other CLI tools. E.g. compiling Compass `compass compile` or get the current git branch `git branch`.
5+
A good way to interact with other CLI tools. For example, get the current Git branch with `git branch`.
66

77
**Use [Stack Overflow](https://stackoverflow.com/questions/tagged/gruntjs) for support questions.**
88

9-
---
10-
11-
<p align="center"><b>🔥 Want to strengthen your core JavaScript skills and master ES6?</b><br>I would personally recommend this awesome <a href="https://ES6.io/friend/AWESOME">ES6 course</a> by Wes Bos.</p>
12-
13-
---
14-
159

1610
## Install
1711

1812
```
1913
$ npm install --save-dev grunt-shell
2014
```
2115

16+
<a href="https://www.patreon.com/sindresorhus">
17+
<img src="https://c5.patreon.com/external/logo/[email protected]" width="160">
18+
</a>
19+
2220

2321
## Usage
2422

2523
```js
26-
require('load-grunt-tasks')(grunt); // npm install --save-dev load-grunt-tasks
24+
require('load-grunt-tasks')(grunt);
2725

2826
grunt.initConfig({
2927
shell: {
@@ -33,7 +31,7 @@ grunt.initConfig({
3331
target: {
3432
command: 'ls'
3533
},
36-
another: 'ls ./src' // shorthand
34+
another: 'ls ./src' // Shorthand
3735
}
3836
});
3937

@@ -90,7 +88,7 @@ module.exports = grunt => {
9088
grunt.initConfig({
9189
shell: {
9290
greet: {
93-
command: greeting => 'echo ' + greeting
91+
command: greeting => `echo ${greeting}`
9492
}
9593
}
9694
});
@@ -117,14 +115,14 @@ grunt.initConfig({
117115
Do whatever you want with the output.
118116

119117
```js
120-
function log(err, stdout, stderr, cb) {
121-
if (err) {
122-
cb(err);
118+
function log(error, stdout, stderr, callback) {
119+
if (error) {
120+
callback(error);
123121
return;
124122
}
125123

126124
console.log(stdout);
127-
cb();
125+
callback();
128126
}
129127

130128
grunt.initConfig({
@@ -141,7 +139,7 @@ grunt.initConfig({
141139

142140
### Option passed to the .exec() method
143141

144-
Run a command in another directory. In this example we run it in a subfolder using the `cwd` (current working directory) option.
142+
Run a command in another directory. In this example, we run it in a subfolder using the `cwd` (current working directory) option.
145143

146144
```js
147145
grunt.initConfig({
@@ -233,13 +231,13 @@ Default: `false`
233231

234232
Set `stdin` to [act as a raw device](https://nodejs.org/api/tty.html#tty_readstream_setrawmode_mode).
235233

236-
### callback(err, stdout, stderr, cb)
234+
### callback(error, stdout, stderr, callback)
237235

238236
Type: `Function`
239237

240238
Lets you override the default callback with your own.
241239

242-
**Make sure to call the `cb` method when you're done.** Supply an error as the first argument to `cb` to print a warning and cause the task to fail.
240+
**Make sure to call the `callback` method when you're done.** Supply an error as the first argument to `callback` to print a warning and cause the task to fail.
243241

244242
### preferLocal
245243

tasks/shell.js

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
'use strict';
2-
const exec = require('child_process').exec;
2+
const {exec} = require('child_process');
33
const chalk = require('chalk');
44
const npmRunPath = require('npm-run-path');
55

66
const TEN_MEGABYTES = 1000 * 1000 * 10;
77

88
module.exports = grunt => {
9-
grunt.registerMultiTask('shell', 'Run shell commands', function () {
10-
const cb = this.async();
11-
const opts = this.options({
9+
grunt.registerMultiTask('shell', 'Run shell commands', function (...args) {
10+
const callback = this.async();
11+
const options = this.options({
1212
stdout: true,
1313
stderr: true,
1414
stdin: true,
@@ -20,7 +20,7 @@ module.exports = grunt => {
2020
}
2121
});
2222

23-
let cmd = typeof this.data === 'string' || typeof this.data === 'function' ?
23+
let cmd = (typeof this.data === 'string' || typeof this.data === 'function') ?
2424
this.data :
2525
this.data.command;
2626

@@ -29,27 +29,27 @@ module.exports = grunt => {
2929
}
3030

3131
// Increase max buffer
32-
opts.execOptions = Object.assign({}, opts.execOptions);
33-
opts.execOptions.maxBuffer = opts.execOptions.maxBuffer || TEN_MEGABYTES;
32+
options.execOptions = Object.assign({}, options.execOptions);
33+
options.execOptions.maxBuffer = options.execOptions.maxBuffer || TEN_MEGABYTES;
3434

35-
cmd = grunt.template.process(typeof cmd === 'function' ? cmd.apply(grunt, arguments) : cmd);
35+
cmd = grunt.template.process(typeof cmd === 'function' ? cmd.apply(grunt, args) : cmd);
3636

37-
if (opts.preferLocal === true) {
38-
opts.execOptions.env = npmRunPath.env({env: opts.execOptions.env || process.env});
37+
if (options.preferLocal === true) {
38+
options.execOptions.env = npmRunPath.env({env: options.execOptions.env || process.env});
3939
}
4040

4141
if (this.data.cwd) {
42-
opts.execOptions.cwd = this.data.cwd;
42+
options.execOptions.cwd = this.data.cwd;
4343
}
4444

45-
const cp = exec(cmd, opts.execOptions, (err, stdout, stderr) => {
46-
if (typeof opts.callback === 'function') {
47-
opts.callback.call(this, err, stdout, stderr, cb);
45+
const cp = exec(cmd, options.execOptions, (error, stdout, stderr) => {
46+
if (typeof options.callback === 'function') {
47+
options.callback.call(this, error, stdout, stderr, callback);
4848
} else {
49-
if (err && opts.failOnError) {
50-
grunt.warn(err);
49+
if (error && options.failOnError) {
50+
grunt.warn(error);
5151
}
52-
cb();
52+
callback();
5353
}
5454
});
5555

@@ -65,19 +65,19 @@ module.exports = grunt => {
6565

6666
grunt.verbose.writeln('Command:', chalk.yellow(cmd));
6767

68-
if (opts.stdout || grunt.option('verbose')) {
68+
if (options.stdout || grunt.option('verbose')) {
6969
captureOutput(cp.stdout, process.stdout);
7070
}
7171

72-
if (opts.stderr || grunt.option('verbose')) {
72+
if (options.stderr || grunt.option('verbose')) {
7373
captureOutput(cp.stderr, process.stderr);
7474
}
7575

76-
if (opts.stdin) {
76+
if (options.stdin) {
7777
process.stdin.resume();
7878
process.stdin.setEncoding('utf8');
7979

80-
if (opts.stdinRawMode && process.stdin.isTTY) {
80+
if (options.stdinRawMode && process.stdin.isTTY) {
8181
process.stdin.setRawMode(true);
8282
}
8383

0 commit comments

Comments
 (0)