From 62bb3cff33f93f624498b4ca0f49a655c3c8200b 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.markdown | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/doc/api/child_process.markdown b/doc/api/child_process.markdown index a7d7a55d8106e1..cc8b8ce8c67b97 100644 --- a/doc/api/child_process.markdown +++ b/doc/api/child_process.markdown @@ -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}`); }); ```