Skip to content

Commit 520369d

Browse files
committed
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: #6660 Reviewed-By: Myles Borins <[email protected]> Reviewed-By: Jeremy Whitlock <[email protected]>
1 parent 51d1960 commit 520369d

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

doc/api/child_process.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -140,13 +140,13 @@ generated output.
140140

141141
```js
142142
const exec = require('child_process').exec;
143-
const child = exec('cat *.js bad_file | wc -l',
144-
(error, stdout, stderr) => {
145-
console.log(`stdout: ${stdout}`);
146-
console.log(`stderr: ${stderr}`);
147-
if (error !== null) {
148-
console.log(`exec error: ${error}`);
149-
}
143+
exec('cat *.js bad_file | wc -l', (error, stdout, stderr) => {
144+
if (error) {
145+
console.error(`exec error: ${error}`);
146+
return;
147+
}
148+
console.log(`stdout: ${stdout}`);
149+
console.log(`stderr: ${stderr}`);
150150
});
151151
```
152152

0 commit comments

Comments
 (0)