Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3e9288e

Browse filesBrowse files
evanlucasMyles Borins
authored andcommitted
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 <myles.borins@gmail.com> Reviewed-By: Jeremy Whitlock <jwhitlock@apache.org>
1 parent 8b396e3 commit 3e9288e
Copy full SHA for 3e9288e

File tree

Expand file treeCollapse file tree

1 file changed

+7
-7
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+7
-7
lines changed
Open diff view settings
Collapse file

‎doc/api/child_process.markdown‎

Copy file name to clipboardExpand all lines: doc/api/child_process.markdown
+7-7Lines changed: 7 additions & 7 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,13 @@ generated output.
139139

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

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.