Skip to content

Commit

Permalink
use process exit listener instead of process.exit()
Browse files Browse the repository at this point in the history
ensures that console.log is fully flushed on Windows before exiting
completely
  • Loading branch information
jquense committed Jan 23, 2015
1 parent 7ddfd0d commit 6eaf8ca
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions bin/jest.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,12 @@ var argv = optimist

if (argv.help) {
optimist.showHelp();
process.exit(0);

process.on('exit', function(){
process.exit(1);
});

return;
}

var cwd = process.cwd();
Expand Down Expand Up @@ -145,7 +150,12 @@ if (fs.existsSync(cwdJestBinPath)) {
'installed globally.\n' +
'Please upgrade this project past Jest version 0.1.5'
);
process.exit(1);

process.on('exit', function(){
process.exit(1);
});

return;
}
} else {
// Otherwise, load this version of Jest.
Expand All @@ -165,7 +175,12 @@ if (fs.existsSync(cwdJestBinPath)) {
'Please run `npm install` to use the version of Jest intended for ' +
'this project.'
);
process.exit(1);

process.on('exit', function(){
process.exit(1);
});

return;
}
}
}
Expand All @@ -175,5 +190,7 @@ if (!argv.version) {
}

jest.runCLI(argv, cwdPackageRoot, function (success) {
process.exit(success ? 0 : 1);
process.on('exit', function(){
process.exit(success ? 0 : 1);
});
});

0 comments on commit 6eaf8ca

Please sign in to comment.