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

Temporarily remove Grunt's uncaughtException listeners. #103

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
21 changes: 20 additions & 1 deletion tasks/grunt-karma.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,26 @@ module.exports = function(grunt) {
done();
}
else {
server.start(data, finished.bind(done));
//listen for SIGINT and take care of stopping the process *after* karma
//stopped all browsers
var sigint = false;
var sigintListener = function() { sigint = true };
process.on('SIGINT', sigintListener);
//temporarily remove Grunt's uncaughtException listener, so that
//karma can handle these and stop any running browsers
var uncaughtListeners = process.listeners('uncaughtException');
process.removeAllListeners('uncaughtException');

function resetListeners(result) {
uncaughtListeners.forEach(process.on.bind(process, 'uncaughtException'));
process.removeListener('SIGINT', sigintListener);
done(result);
if( sigint ) {
process.exit(130);
}
}

server.start(data, finished.bind(resetListeners));
}
});
};
Expand Down