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 <myles.borins@gmail.com>
Reviewed-By: Jeremy Whitlock <jwhitlock@apache.org>
  • Loading branch information
evanlucas authored and Myles Borins committed Jun 2, 2016
1 parent 97fa50a commit ffa8bcd
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions doc/api/child_process.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,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 ffa8bcd

Please sign in to comment.