@@ -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 ();
@@ -850,7 +850,7 @@ as in this example:
850
850
' use strict' ;
851
851
const spawn = require (' child_process' ).spawn ;
852
852
853
- let child = spawn (' sh' , [' -c' ,
853
+ const child = spawn (' sh' , [' -c' ,
854
854
` node -e "setInterval(() => {
855
855
console.log(process.pid, 'is alive')
856
856
}, 500);"`
@@ -1097,21 +1097,21 @@ const fs = require('fs');
1097
1097
const child_process = require (' child_process' );
1098
1098
1099
1099
const child = child_process .spawn (' ls' , {
1100
- stdio: [
1101
- 0 , // Use parents stdin for child
1102
- ' pipe' , // Pipe child's stdout to parent
1103
- fs .openSync (' err.out' , ' w' ) // Direct child's stderr to a file
1104
- ]
1100
+ stdio: [
1101
+ 0 , // Use parent's stdin for child
1102
+ ' pipe' , // Pipe child's stdout to parent
1103
+ fs .openSync (' err.out' , ' w' ) // Direct child's stderr to a file
1104
+ ]
1105
1105
});
1106
1106
1107
- assert .equal (child .stdio [0 ], null );
1108
- assert .equal (child .stdio [0 ], child .stdin );
1107
+ assert .strictEqual (child .stdio [0 ], null );
1108
+ assert .strictEqual (child .stdio [0 ], child .stdin );
1109
1109
1110
1110
assert (child .stdout );
1111
- assert .equal (child .stdio [1 ], child .stdout );
1111
+ assert .strictEqual (child .stdio [1 ], child .stdout );
1112
1112
1113
- assert .equal (child .stdio [2 ], null );
1114
- assert .equal (child .stdio [2 ], child .stderr );
1113
+ assert .strictEqual (child .stdio [2 ], null );
1114
+ assert .strictEqual (child .stdio [2 ], child .stderr );
1115
1115
```
1116
1116
1117
1117
### child.stdout
0 commit comments