Fix for watch configs with "default" target name. Fixes GH-312.
This commit is contained in:
parent
95e415db71
commit
c92448d418
@ -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];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user