async teardown and .grunt removal, closes #58

This commit is contained in:
Jarrod Overson 2013-06-15 11:50:37 -07:00
parent 3bde360e05
commit e622be01c6
3 changed files with 13 additions and 9 deletions

View File

@ -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",

View File

@ -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) {

View File

@ -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){