diff --git a/package.json b/package.json index f943cd2..67c57e4 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ }, "dependencies": { "grunt-lib-phantomjs": "~0.3.0", - "rimraf": "~2.0.3" + "rimraf": "~2.1.4" }, "devDependencies": { "grunt-contrib-internal": "~0.4.0", diff --git a/tasks/jasmine.js b/tasks/jasmine.js index 13274b6..bd23731 100644 --- a/tasks/jasmine.js +++ b/tasks/jasmine.js @@ -68,8 +68,9 @@ module.exports = function(grunt) { else grunt.log.error(status.failed + ' failures'); options.keepRunner = options.keepRunner || !success; - teardown(options); - done(success); + teardown(options, function(){ + done(success); + }); }); }); @@ -99,12 +100,12 @@ module.exports = function(grunt) { }); } - function teardown(options) { - if (!options.keepRunner && fs.statSync(options.outfile).isFile()) fs.unlink(options.outfile); - if (!options.keepRunner) jasmine.cleanTemp(); - + function teardown(options, cb) { phantomjs.removeAllListeners(); phantomjs.listenersAny().length = 0; + + if (!options.keepRunner && fs.statSync(options.outfile).isFile()) fs.unlink(options.outfile); + if (!options.keepRunner) jasmine.cleanTemp(cb); } function setup(options) { diff --git a/tasks/lib/jasmine.js b/tasks/lib/jasmine.js index 191612f..9ca7a20 100644 --- a/tasks/lib/jasmine.js +++ b/tasks/lib/jasmine.js @@ -24,8 +24,11 @@ exports.init = function(grunt, phantomjs) { grunt.file.copy(src, file); }; - exports.cleanTemp = function() { - rimraf.sync(tempDir); + exports.cleanTemp = function(cb) { + rimraf(tempDir, function(){ + // if this fails, then ./.grunt isn't empty and that's ok. + fs.rmdir('.grunt', cb); + }); }; exports.buildSpecrunner = function (src, options){