@@ -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
// ...
@@ -391,7 +391,7 @@ ps.on('close', (code) => {
391
391
});
392
392
393
393
grep .stdout .on (' data' , (data ) => {
394
- console .log (` ${ data} ` );
394
+ console .log (data . toString () );
395
395
});
396
396
397
397
grep .stderr .on (' data' , (data ) => {
@@ -475,8 +475,8 @@ const out = fs.openSync('./out.log', 'a');
475
475
const err = fs .openSync (' ./out.log' , ' a' );
476
476
477
477
const child = spawn (' prg' , [], {
478
- detached: true ,
479
- stdio: [ ' ignore' , out, err ]
478
+ detached: true ,
479
+ stdio: [ ' ignore' , out, err ]
480
480
});
481
481
482
482
child .unref ();
@@ -876,7 +876,7 @@ as in this example:
876
876
' use strict' ;
877
877
const spawn = require (' child_process' ).spawn ;
878
878
879
- let child = spawn (' sh' , [' -c' ,
879
+ const child = spawn (' sh' , [' -c' ,
880
880
` node -e "setInterval(() => {
881
881
console.log(process.pid, 'is alive')
882
882
}, 500);"`
@@ -1123,21 +1123,21 @@ const fs = require('fs');
1123
1123
const child_process = require (' child_process' );
1124
1124
1125
1125
const child = child_process .spawn (' ls' , {
1126
- stdio: [
1127
- 0 , // Use parents stdin for child
1128
- ' pipe' , // Pipe child's stdout to parent
1129
- fs .openSync (' err.out' , ' w' ) // Direct child's stderr to a file
1130
- ]
1126
+ stdio: [
1127
+ 0 , // Use parent's stdin for child
1128
+ ' pipe' , // Pipe child's stdout to parent
1129
+ fs .openSync (' err.out' , ' w' ) // Direct child's stderr to a file
1130
+ ]
1131
1131
});
1132
1132
1133
- assert .equal (child .stdio [0 ], null );
1134
- assert .equal (child .stdio [0 ], child .stdin );
1133
+ assert .strictEqual (child .stdio [0 ], null );
1134
+ assert .strictEqual (child .stdio [0 ], child .stdin );
1135
1135
1136
1136
assert (child .stdout );
1137
- assert .equal (child .stdio [1 ], child .stdout );
1137
+ assert .strictEqual (child .stdio [1 ], child .stdout );
1138
1138
1139
- assert .equal (child .stdio [2 ], null );
1140
- assert .equal (child .stdio [2 ], child .stderr );
1139
+ assert .strictEqual (child .stdio [2 ], null );
1140
+ assert .strictEqual (child .stdio [2 ], child .stderr );
1141
1141
```
1142
1142
1143
1143
### child.stdout
0 commit comments