Fix for watch configs with "default" target name. Fixes GH-312.

This commit is contained in:
Kyle Robinson Young 2014-03-19 10:37:10 -07:00
parent 95e415db71
commit c92448d418
2 changed files with 13 additions and 4 deletions

View File

@ -20,6 +20,7 @@ module.exports = function(grunt) {
function TaskRun(target) { function TaskRun(target) {
this.name = target.name || 0; this.name = target.name || 0;
this.files = target.files || []; this.files = target.files || [];
this._getConfig = target._getConfig;
this.options = target.options; this.options = target.options;
this.startedAt = false; this.startedAt = false;
this.spawned = null; this.spawned = null;
@ -49,13 +50,13 @@ module.exports = function(grunt) {
// Start this task run // Start this task run
self.startedAt = Date.now(); self.startedAt = Date.now();
//reset before each run // reset before each run
self.spawnTaskFailure = false; self.spawnTaskFailure = false;
self.errorsAndWarningsCount = getErrorCount(); self.errorsAndWarningsCount = getErrorCount();
//pull the tasks here in case they were changed by a watch event listener // pull the tasks here in case they were changed by a watch event listener
self.tasks = grunt.config('watch' + (this.name === 'default' ? '' : '.' + this.name) + '.tasks') || []; self.tasks = self._getConfig('tasks') || [];
if (typeof this.tasks === 'string') { if (typeof self.tasks === 'string') {
self.tasks = [self.tasks]; self.tasks = [self.tasks];
} }

View File

@ -218,7 +218,15 @@ module.exports = function(grunt) {
// Push targets onto the queue // Push targets onto the queue
Runner.prototype.add = function add(target) { Runner.prototype.add = function add(target) {
var self = this;
if (!this.targets[target.name || 0]) { if (!this.targets[target.name || 0]) {
// Private method for getting latest config for a watch target
target._getConfig = function(name) {
return grunt.config([self.name, target.name, name || '']);
};
// Create a new TaskRun instance
var tr = new TaskRun(target); var tr = new TaskRun(target);
// Add livereload to task runs // Add livereload to task runs