diff --git a/tasks/jasmine.js b/tasks/jasmine.js index 68b0d34..9cd2643 100644 --- a/tasks/jasmine.js +++ b/tasks/jasmine.js @@ -61,11 +61,15 @@ module.exports = function(grunt) { var done = this.async(); phantomRunner(options, function(err,status) { + var success = !err && status.failed === 0; + if (err) grunt.log.error(err); if (status.failed === 0) grunt.log.ok('0 failures'); else grunt.log.error(status.failed + ' failures'); + + options.keepRunner = options.keepRunner || !success; teardown(options); - done(!err && status.failed === 0); + done(success); }); }); @@ -96,8 +100,8 @@ module.exports = function(grunt) { } function teardown(options) { - if (fs.statSync(options.outfile).isFile()) fs.unlink(options.outfile); - jasmine.cleanTemp(); + if (!options.keepRunner && fs.statSync(options.outfile).isFile()) fs.unlink(options.outfile); + if (!options.keepRunner) jasmine.cleanTemp(); // Have to explicitly unregister nested wildcards. Need to file a bug for EventEmitter2 phantomjs.removeAllListeners('*');