Browse Source

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>
process-exit-stdio-flushing
Evan Lucas 9 years ago
parent
commit
d13b9d3f7f
  1. 14
      doc/api/child_process.md

14
doc/api/child_process.md

@ -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…
Cancel
Save