doc: fix exec example in child_process
Previously, the example was checking for error by strict equality to null. The error could be undefined though which would fail that check. PR-URL: https://github.com/nodejs/node/pull/6660 Reviewed-By: Myles Borins <myles.borins@gmail.com> Reviewed-By: Jeremy Whitlock <jwhitlock@apache.org>
This commit is contained in:
parent
a661e26300
commit
d13b9d3f7f
@ -140,13 +140,13 @@ generated output.
|
|||||||
|
|
||||||
```js
|
```js
|
||||||
const exec = require('child_process').exec;
|
const exec = require('child_process').exec;
|
||||||
const child = exec('cat *.js bad_file | wc -l',
|
exec('cat *.js bad_file | wc -l', (error, stdout, stderr) => {
|
||||||
(error, stdout, stderr) => {
|
if (error) {
|
||||||
console.log(`stdout: ${stdout}`);
|
console.error(`exec error: ${error}`);
|
||||||
console.log(`stderr: ${stderr}`);
|
return;
|
||||||
if (error !== null) {
|
}
|
||||||
console.log(`exec error: ${error}`);
|
console.log(`stdout: ${stdout}`);
|
||||||
}
|
console.log(`stderr: ${stderr}`);
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user