aboutsummaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorEvan Lucas <evanlucas@me.com>2016-05-09 14:49:03 -0500
committerEvan Lucas <evanlucas@me.com>2016-05-13 08:04:11 -0500
commitd13b9d3f7f59f0be279226bbcde622cceccda369 (patch)
tree5692c7c54a5e27552b89f3ed567ef84d52db75fc /doc
parenta661e263005f6c403659be93b7e64b09e373f913 (diff)
downloadandroid-node-v8-d13b9d3f7f59f0be279226bbcde622cceccda369.tar.gz
android-node-v8-d13b9d3f7f59f0be279226bbcde622cceccda369.tar.bz2
android-node-v8-d13b9d3f7f59f0be279226bbcde622cceccda369.zip
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>
Diffstat (limited to 'doc')
-rw-r--r--doc/api/child_process.md14
1 files changed, 7 insertions, 7 deletions
diff --git a/doc/api/child_process.md b/doc/api/child_process.md
index 32dec46924..61d800cf0d 100644
--- a/doc/api/child_process.md
+++ b/doc/api/child_process.md
@@ -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}`);
});
```