Skip to content

Commit 3d01d64

Browse files
committed
Patched stream closing issue
1 parent ab142f5 commit 3d01d64

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/exec.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,10 @@ function execSync(cmd, opts) {
6363
"childProcess.stderr.pipe(stdoutStream, {end: false});",
6464
"childProcess.stdout.pipe(process.stdout);",
6565
"childProcess.stderr.pipe(process.stderr);",
66-
"process.stdout.on('end', function(){ stdoutStream.end(); });",
67-
"process.stderr.on('end', function(){ stdoutStream.end(); });"
66+
"var stdoutEnded = false, stderrEnded = false;",
67+
"function tryClosing(){ if(stdoutEnded && stderrEnded){ stdoutStream.end(); } }",
68+
"childProcess.stdout.on('end', function(){ stdoutEnded = true; tryClosing(); });",
69+
"childProcess.stderr.on('end', function(){ stderrEnded = true; tryClosing(); });"
6870
].join('\n');
6971

7072
fs.writeFileSync(scriptFile, script);

0 commit comments

Comments
 (0)