Skip to content

Commit

Permalink
Fix cropping of error output when called from another process
Browse files Browse the repository at this point in the history
Use similar method as in mochajs/mocha#333
  • Loading branch information
Jyri Kytömäki committed Aug 21, 2017
1 parent 6c6099b commit 36ad475
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions lib/jasmine-node/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ if (captureExceptions) {
process.on('uncaughtException', function(e) {
console.error(e.stack || e);
exitCode = 1;
process.exit(exitCode);
exitAfterStreamWritesCompleted();
});
}

Expand All @@ -212,10 +212,27 @@ var onComplete = function(runner, log) {
exitCode = 1;
}
if (forceExit) {
process.exit(exitCode);
exitAfterStreamWritesCompleted();
}
};

function exitAfterStreamWritesCompleted() {
var streams = [process.stdout, process.stderr];
var writesToWait = streams.length;

streams.forEach(function(stream){
// submit empty write request and wait for completion
stream.write('', exitIfAllStreamsCompleted);
});

function exitIfAllStreamsCompleted() {
writesToWait--;
if (writesToWait == 0) {
process.exit(exitCode);
}
}
}

if(useHelpers){
specFolders.forEach(function(path){
jasmine.loadHelpersInFolder(path,
Expand Down

0 comments on commit 36ad475

Please sign in to comment.