Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

workaround for windows to ensure console.log is always flushed before pr... #111

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions bin/jest.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,9 @@ function _main(onComplete) {

if (argv.help) {
optimist.showHelp();
process.exit(0);
process.on('exit', function(){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, hadn't heard of this before...but seems to be a KP: https://www.npmjs.org/package/exit

One thing we need to be sure of on these changes is that execution doesn't continue after exiting (which was part of the intent of those exits before). So we either need to refactor the scripts so they can return early after setting up this listener, or find a way to make sure that the remaining code doesn't continue to execute if we hit this branch in the code path.

process.exit(0);
});
}

var cwd = process.cwd();
Expand Down Expand Up @@ -358,7 +360,9 @@ function _main(onComplete) {
'installed globally.\n' +
'Please upgrade this project past Jest version 0.1.5'
);
process.exit(1);
process.on('exit', function(){
process.exit(1);
});
}

jestBinary.runCLI(argv, cwdPackageRoot, onComplete);
Expand All @@ -381,7 +385,9 @@ function _main(onComplete) {
'Please run `npm install` to use the version of Jest intended for ' +
'this project.'
);
process.exit(1);
process.on('exit', function(){
process.exit(1);
});
}
}

Expand All @@ -396,6 +402,8 @@ exports.runCLI = runCLI;
if (require.main === module) {
harmonize();
_main(function (success) {
process.exit(success ? 0 : 1);
process.on('exit', function(){
process.exit(success ? 0 : 1);
});
});
}