@@ -91,11 +91,11 @@ const spawn = require('child_process').spawn;
91
91
const bat = spawn (' cmd.exe' , [' /c' , ' my.bat' ]);
92
92
93
93
bat .stdout .on (' data' , (data ) => {
94
- console .log (data);
94
+ console .log (data . toString () );
95
95
});
96
96
97
97
bat .stderr .on (' data' , (data ) => {
98
- console .log (data);
98
+ console .log (data . toString () );
99
99
});
100
100
101
101
bat .on (' exit' , (code ) => {
@@ -113,7 +113,7 @@ exec('my.bat', (err, stdout, stderr) => {
113
113
});
114
114
115
115
// Script with spaces in the filename:
116
- const bat = spawn (' "my script.cmd"' , [' a' , ' b' ], { shell: true });
116
+ const bat = spawn (' "my script.cmd"' , [' a' , ' b' ], { shell: true });
117
117
// or:
118
118
exec (' "my script.cmd" a b' , (err , stdout , stderr ) => {
119
119
// ...
@@ -383,7 +383,7 @@ ps.on('close', (code) => {
383
383
});
384
384
385
385
grep .stdout .on (' data' , (data ) => {
386
- console .log (` ${ data} ` );
386
+ console .log (data . toString () );
387
387
});
388
388
389
389
grep .stderr .on (' data' , (data ) => {
@@ -467,8 +467,8 @@ const out = fs.openSync('./out.log', 'a');
467
467
const err = fs .openSync (' ./out.log' , ' a' );
468
468
469
469
const child = spawn (' prg' , [], {
470
- detached: true ,
471
- stdio: [ ' ignore' , out, err ]
470
+ detached: true ,
471
+ stdio: [ ' ignore' , out, err ]
472
472
});
473
473
474
474
child .unref ();
@@ -860,7 +860,7 @@ as in this example:
860
860
' use strict' ;
861
861
const spawn = require (' child_process' ).spawn ;
862
862
863
- let child = spawn (' sh' , [' -c' ,
863
+ const child = spawn (' sh' , [' -c' ,
864
864
` node -e "setInterval(() => {
865
865
console.log(process.pid, 'is alive')
866
866
}, 500);"`
@@ -1107,21 +1107,21 @@ const fs = require('fs');
1107
1107
const child_process = require (' child_process' );
1108
1108
1109
1109
const child = child_process .spawn (' ls' , {
1110
- stdio: [
1111
- 0 , // Use parents stdin for child
1112
- ' pipe' , // Pipe child's stdout to parent
1113
- fs .openSync (' err.out' , ' w' ) // Direct child's stderr to a file
1114
- ]
1110
+ stdio: [
1111
+ 0 , // Use parent's stdin for child
1112
+ ' pipe' , // Pipe child's stdout to parent
1113
+ fs .openSync (' err.out' , ' w' ) // Direct child's stderr to a file
1114
+ ]
1115
1115
});
1116
1116
1117
- assert .equal (child .stdio [0 ], null );
1118
- assert .equal (child .stdio [0 ], child .stdin );
1117
+ assert .strictEqual (child .stdio [0 ], null );
1118
+ assert .strictEqual (child .stdio [0 ], child .stdin );
1119
1119
1120
1120
assert (child .stdout );
1121
- assert .equal (child .stdio [1 ], child .stdout );
1121
+ assert .strictEqual (child .stdio [1 ], child .stdout );
1122
1122
1123
- assert .equal (child .stdio [2 ], null );
1124
- assert .equal (child .stdio [2 ], child .stderr );
1123
+ assert .strictEqual (child .stdio [2 ], null );
1124
+ assert .strictEqual (child .stdio [2 ], child .stderr );
1125
1125
```
1126
1126
1127
1127
### child.stdout
0 commit comments