Skip to content

Commit

Permalink
Patched stream closing issue
Browse files Browse the repository at this point in the history
  • Loading branch information
JulianLaval committed Aug 11, 2015
1 parent ab142f5 commit 3d01d64
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/exec.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,10 @@ function execSync(cmd, opts) {
"childProcess.stderr.pipe(stdoutStream, {end: false});",
"childProcess.stdout.pipe(process.stdout);",
"childProcess.stderr.pipe(process.stderr);",
"process.stdout.on('end', function(){ stdoutStream.end(); });",
"process.stderr.on('end', function(){ stdoutStream.end(); });"
"var stdoutEnded = false, stderrEnded = false;",
"function tryClosing(){ if(stdoutEnded && stderrEnded){ stdoutStream.end(); } }",
"childProcess.stdout.on('end', function(){ stdoutEnded = true; tryClosing(); });",
"childProcess.stderr.on('end', function(){ stderrEnded = true; tryClosing(); });"
].join('\n');

fs.writeFileSync(scriptFile, script);
Expand Down

0 comments on commit 3d01d64

Please sign in to comment.