From 64902fe3d99fdddabdfceb0d3fcc8de851c2336b Mon Sep 17 00:00:00 2001 From: Kyle Robinson Young Date: Mon, 27 May 2013 11:39:07 -0700 Subject: [PATCH] Ensure tasks are an array. Fixes GH-115. --- tasks/lib/taskrun.js | 3 +++ test/fixtures/multiTargets/Gruntfile.js | 14 +++++++------- test/fixtures/oneTarget/Gruntfile.js | 8 +++++--- test/tasks/watch_test.js | 2 +- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/tasks/lib/taskrun.js b/tasks/lib/taskrun.js index 30ecdb1..2712867 100644 --- a/tasks/lib/taskrun.js +++ b/tasks/lib/taskrun.js @@ -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 diff --git a/test/fixtures/multiTargets/Gruntfile.js b/test/fixtures/multiTargets/Gruntfile.js index 6de4460..d4204f7 100644 --- a/test/fixtures/multiTargets/Gruntfile.js +++ b/test/fixtures/multiTargets/Gruntfile.js @@ -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'); diff --git a/test/fixtures/oneTarget/Gruntfile.js b/test/fixtures/oneTarget/Gruntfile.js index ea8ebe2..e35871c 100644 --- a/test/fixtures/oneTarget/Gruntfile.js +++ b/test/fixtures/oneTarget/Gruntfile.js @@ -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'); diff --git a/test/tasks/watch_test.js b/test/tasks/watch_test.js index 97cdcc0..85eb580 100644 --- a/test/tasks/watch_test.js +++ b/test/tasks/watch_test.js @@ -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);