From 520369d8e0cd69eff42f68970c4b5a25b5fd15dd 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 9112e72e063c9f..dab853c0bfff8c 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}`); }); ```