diff --git a/index.js b/index.js index a46d513..c5e7fb0 100644 --- a/index.js +++ b/index.js @@ -34,7 +34,10 @@ function verifyTaskSets(gulp, taskSets, skipArrays) { } function runSequence(gulp) { - var taskSets = Array.prototype.slice.call(arguments, 1), + // Slice and dice the input to prevent modification of parallel arrays. + var taskSets = Array.prototype.slice.call(arguments, 1).map(function(task) { + return Array.isArray(task) ? task.slice() : task; + }), callBack = typeof taskSets[taskSets.length-1] === 'function' ? taskSets.pop() : false, currentTaskSet, diff --git a/test/main.js b/test/main.js index b91f5d8..b238dcc 100644 --- a/test/main.js +++ b/test/main.js @@ -74,6 +74,14 @@ describe('runSequence', function() { }) }); + describe('Input Array Handling', function() { + it('should not modify passed-in parallel task arrays', function() { + var taskArray = ['task1', 'task2']; + runSequence(taskArray); + taskArray.should.eql(['task1', 'task2']); + }); + }); + describe('Asynchronous Tasks', function() { it('should run a single task', function() { task1.shouldPause = true;