Skip to content

Commit

Permalink
doc: fix exec example in child_process
Browse files Browse the repository at this point in the history
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: #6660
Reviewed-By: Myles Borins <[email protected]>
Reviewed-By: Jeremy Whitlock <[email protected]>
  • Loading branch information
evanlucas committed May 13, 2016
1 parent a661e26 commit d13b9d3
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions doc/api/child_process.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,13 @@ generated output.

```js
const exec = require('child_process').exec;
const child = exec('cat *.js bad_file | wc -l',
(error, stdout, stderr) => {
console.log(`stdout: ${stdout}`);
console.log(`stderr: ${stderr}`);
if (error !== null) {
console.log(`exec error: ${error}`);
}
exec('cat *.js bad_file | wc -l', (error, stdout, stderr) => {
if (error) {
console.error(`exec error: ${error}`);
return;
}
console.log(`stdout: ${stdout}`);
console.log(`stderr: ${stderr}`);
});
```

Expand Down

0 comments on commit d13b9d3

Please sign in to comment.