Skip to content

Commit

Permalink
added wait option
Browse files Browse the repository at this point in the history
  • Loading branch information
mokkabonna committed Aug 31, 2013
1 parent b32f782 commit 6dfd26a
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions tasks/grunt-karma.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,24 @@ module.exports = function(grunt) {
runner.run(data, done);
return;
}

//allow karma to be run in the background so it doesn't block grunt
if (data.background){
grunt.util.spawn({cmd: 'node', args: [path.join(__dirname, '..', 'lib', 'background.js'), JSON.stringify(data)]}, function(){});
done();
var callback = function() {};
//if wait option is on run karma in the background but wait for it to finish before continuing task execution
//avoids having multiple karma servers running if running more than once in the same task queue
if(data.wait){
callback = function(error, result, code) {
grunt.log.writeln(result.stdout);
if(result.stderr) grunt.warn(result.stderr);
done(code === 0);
};
}

grunt.util.spawn({cmd: 'node', args: [path.join(__dirname, '..', 'lib', 'background.js'), JSON.stringify(data)]}, callback);

//finish immediately
if (!data.wait) done();
}
else {
server.start(data, finished.bind(done));
Expand Down

0 comments on commit 6dfd26a

Please sign in to comment.