Skip to content

Commit

Permalink
Require Node.js 6
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Jun 22, 2018
1 parent 7488ce9 commit 49518e1
Show file tree
Hide file tree
Showing 9 changed files with 116 additions and 116 deletions.
3 changes: 1 addition & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
* text=auto
*.js text eol=lf
* text=auto eol=lf
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
yarn.lock
.nyc_output
coverage
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
language: node_js
node_js:
- '10'
- '8'
- '6'
- '4'
before_install:
- npm install --global npm@3
after_script:
- 'cat coverage/lcov.info | ./node_modules/.bin/coveralls'
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
environment:
matrix:
- nodejs_version: '10'
- nodejs_version: '8'
- nodejs_version: '6'
- nodejs_version: '4'
install:
- ps: Install-Product node $env:nodejs_version
- npm install --global npm@latest
Expand Down
12 changes: 4 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,15 +308,11 @@ module.exports = (cmd, args, opts) => {
return spawned;
};

module.exports.stdout = function (...args) {
// TODO: set `stderr: 'ignore'` when that option is implemented
return module.exports(...args).then(x => x.stdout);
};
// TODO: set `stderr: 'ignore'` when that option is implemented
module.exports.stdout = (...args) => module.exports(...args).then(x => x.stdout);

module.exports.stderr = function (...args) {
// TODO: set `stdout: 'ignore'` when that option is implemented
return module.exports(...args).then(x => x.stderr);
};
// TODO: set `stdout: 'ignore'` when that option is implemented
module.exports.stderr = (...args) => module.exports(...args).then(x => x.stderr);

module.exports.shell = (cmd, opts) => handleShell(module.exports, cmd, opts);

Expand Down
2 changes: 1 addition & 1 deletion lib/errname.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';
// Older verions of Node might not have `util.getSystemErrorName()`.
// Older verions of Node.js might not have `util.getSystemErrorName()`.
// In that case, fall back to a deprecated internal.
const util = require('util');

Expand Down
141 changes: 67 additions & 74 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,76 +1,69 @@
{
"name": "execa",
"version": "0.10.0",
"description": "A better `child_process`",
"license": "MIT",
"repository": "sindresorhus/execa",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"maintainers": [
{
"name": "James Talmage",
"email": "james@talmage.io",
"url": "github.com/jamestalmage"
}
],
"engines": {
"node": ">=4"
},
"scripts": {
"test": "xo && nyc ava"
},
"files": [
"index.js",
"lib"
],
"keywords": [
"exec",
"child",
"process",
"execute",
"fork",
"execfile",
"spawn",
"file",
"shell",
"bin",
"binary",
"binaries",
"npm",
"path",
"local"
],
"dependencies": {
"cross-spawn": "^6.0.0",
"get-stream": "^3.0.0",
"is-stream": "^1.1.0",
"npm-run-path": "^2.0.0",
"p-finally": "^1.0.0",
"signal-exit": "^3.0.0",
"strip-eof": "^1.0.0"
},
"devDependencies": {
"ava": "*",
"cat-names": "^1.0.2",
"coveralls": "^2.11.9",
"delay": "^2.0.0",
"is-running": "^2.0.0",
"nyc": "^11.0.2",
"tempfile": "^2.0.0",
"xo": "*"
},
"nyc": {
"reporter": [
"text",
"lcov"
],
"exclude": [
"**/fixtures/**",
"**/test.js",
"**/test/**"
]
}
"name": "execa",
"version": "0.10.0",
"description": "A better `child_process`",
"license": "MIT",
"repository": "sindresorhus/execa",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=6"
},
"scripts": {
"test": "xo && nyc ava"
},
"files": [
"index.js",
"lib"
],
"keywords": [
"exec",
"child",
"process",
"execute",
"fork",
"execfile",
"spawn",
"file",
"shell",
"bin",
"binary",
"binaries",
"npm",
"path",
"local"
],
"dependencies": {
"cross-spawn": "^6.0.0",
"get-stream": "^3.0.0",
"is-stream": "^1.1.0",
"npm-run-path": "^2.0.0",
"p-finally": "^1.0.0",
"signal-exit": "^3.0.0",
"strip-eof": "^1.0.0"
},
"devDependencies": {
"ava": "*",
"cat-names": "^1.0.2",
"coveralls": "^3.0.1",
"delay": "^3.0.0",
"is-running": "^2.0.0",
"nyc": "^12.0.2",
"tempfile": "^2.0.0",
"xo": "*"
},
"nyc": {
"reporter": [
"text",
"lcov"
],
"exclude": [
"**/fixtures/**",
"**/test.js",
"**/test/**"
]
}
}
66 changes: 39 additions & 27 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,41 +30,53 @@ $ npm install execa
```js
const execa = require('execa');

execa('echo', ['unicorns']).then(result => {
console.log(result.stdout);
(async () => {
const {stdout} = await execa('echo', ['unicorns']);
console.log(stdout);
//=> 'unicorns'
});
})();
```

Additional examples:

```js
const execa = require('execa');

// pipe the child process stdout to the current stdout
execa('echo', ['unicorns']).stdout.pipe(process.stdout);
(async () => {
// Pipe the child process stdout to the current stdout
execa('echo', ['unicorns']).stdout.pipe(process.stdout);

execa.shell('echo unicorns').then(result => {
console.log(result.stdout);

// Run a shell command
const {stdout} = await execa.shell('echo unicorns');
//=> 'unicorns'
});

// example of catching an error
execa.shell('exit 3').catch(error => {
console.log(error);
/*
{
message: 'Command failed: /bin/sh -c exit 3'
killed: false,
code: 3,
signal: null,
cmd: '/bin/sh -c exit 3',
stdout: '',
stderr: '',
timedOut: false

// Catching an error
try {
await execa.shell('exit 3');
} catch (error) {
console.log(error);
/*
{
message: 'Command failed: /bin/sh -c exit 3'
killed: false,
code: 3,
signal: null,
cmd: '/bin/sh -c exit 3',
stdout: '',
stderr: '',
timedOut: false
}
*/
}
*/
});
})();

// example of catching an error with a sync method
// Catching an error with a sync method
try {
execa.shellSync('exit 3');
} catch (err) {
console.log(err);
} catch (error) {
console.log(error);
/*
{
message: 'Command failed: /bin/sh -c exit 3'
Expand Down Expand Up @@ -153,7 +165,7 @@ Explicitly set the value of `argv[0]` sent to the child process. This will be se

#### stdio

Type: `Array` `string`<br>
Type: `string[]` `string`<br>
Default: `pipe`

Child's [stdio](https://nodejs.org/api/child_process.html#child_process_options_stdio) configuration.
Expand Down

0 comments on commit 49518e1

Please sign in to comment.