Ensure tasks are an array. Fixes GH-115.

This commit is contained in:
Kyle Robinson Young 2013-05-27 11:39:07 -07:00
parent d83c44eb93
commit 64902fe3d9
4 changed files with 16 additions and 11 deletions

View File

@ -25,6 +25,9 @@ module.exports = function(grunt) {
this.startedAt = false;
this.spawned = null;
this.changedFiles = Object.create(null);
if (typeof this.tasks === 'string') {
this.tasks = [this.tasks];
}
}
// Run it

View File

@ -11,26 +11,26 @@ module.exports = function(grunt) {
watch: {
one: {
files: ['lib/one.js', 'Gruntfile.js'],
tasks: ['echo:one']
tasks: 'echo:one',
},
two: {
files: ['lib/two.js'],
tasks: ['echo:two']
tasks: ['echo:two'],
},
wait: {
files: ['lib/wait.js'],
tasks: ['echo:wait']
tasks: ['echo:wait'],
},
interrupt: {
files: ['lib/interrupt.js'],
tasks: ['echo:interrupt'],
options: { interrupt: true }
options: { interrupt: true },
},
fail: {
files: ['lib/fail.js'],
tasks: ['echo:fail']
}
}
tasks: ['echo:fail'],
},
},
});
// Load the echo task
grunt.loadTasks('../tasks');

View File

@ -2,12 +2,14 @@ module.exports = function(grunt) {
'use strict';
grunt.initConfig({
echo: {
files: ['lib/*.js']
files: ['lib/*.js'],
},
watch: {
files: ['<%= echo.files %>'],
tasks: ['echo']
}
// Dont make tasks an array
// To ensure it works with cliArgs: See #115
tasks: 'echo',
},
});
// Load the echo task
grunt.loadTasks('../tasks');

View File

@ -29,7 +29,7 @@ exports.watchConfig = {
oneTarget: function(test) {
test.expect(2);
var cwd = path.resolve(fixtures, 'oneTarget');
var assertWatch = helper.assertTask('watch', {cwd:cwd});
var assertWatch = helper.assertTask(['watch', '--debug'], {cwd:cwd});
assertWatch(function() {
var write = 'var test = true;';
grunt.file.write(path.join(cwd, 'lib', 'one.js'), write);