diff --git a/tasks/watch.js b/tasks/watch.js index e309d1c..aa2e106 100644 --- a/tasks/watch.js +++ b/tasks/watch.js @@ -82,6 +82,18 @@ module.exports = function(grunt) { // initialize taskrun var targets = taskrun.init(name, {target: target}); + var targetsReady = targets.length; + function watcherIsReady() { + targetsReady--; + + // Take action when all Gaze tasks report ready + if(targetsReady < 1) { + // Emit ready event if anyone is listening + if (grunt.event.listeners('watch-ready').length > 0) { + grunt.event.emit('watch-ready'); + } + } + } targets.forEach(function(target, i) { if (typeof target.files === 'string') { target.files = [target.files]; } @@ -170,6 +182,9 @@ module.exports = function(grunt) { if (typeof err === 'string') { err = new Error(err); } grunt.log.error(err.message); }); + + // + watcherIsReady(); })); });