From d13b9d3f7f59f0be279226bbcde622cceccda369 Mon Sep 17 00:00:00 2001 From: Evan Lucas Date: Mon, 9 May 2016 14:49:03 -0500 Subject: [PATCH] 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 Reviewed-By: Jeremy Whitlock --- doc/api/child_process.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/doc/api/child_process.md b/doc/api/child_process.md index 32dec46924f1ad..61d800cf0d4312 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}`); }); ```