From 77ea8394f1d18573f7c8254e8de58f82b6d9e156 Mon Sep 17 00:00:00 2001 From: "Todd H. Gardner" Date: Fri, 24 Oct 2014 09:21:45 -0500 Subject: [PATCH] changed file arguments to loop over task.data.files.src. Updated common test fixture to construct the fake task with this data structure. --- lib/command_add.js | 6 ++---- lib/command_clean.js | 6 ++---- lib/command_commit.js | 6 ++---- lib/command_reset.js | 10 +++------- test/_common.js | 8 ++++---- test/add_test.js | 4 ++-- 6 files changed, 15 insertions(+), 25 deletions(-) diff --git a/lib/command_add.js b/lib/command_add.js index a659121..90eac97 100644 --- a/lib/command_add.js +++ b/lib/command_add.js @@ -23,10 +23,8 @@ module.exports = function (task, exec, done) { var options = argUtil.options; var args = ['add'].concat(argUtil.getArgFlags()); - task.files.forEach(function (files) { - for (var i = 0; i < files.src.length; i++) { - args.push(files.src[i]); - } + task.data.files.src.forEach(function (file) { + args.push(file); }); args.push(done); diff --git a/lib/command_clean.js b/lib/command_clean.js index 9ae531e..a861f26 100644 --- a/lib/command_clean.js +++ b/lib/command_clean.js @@ -60,10 +60,8 @@ module.exports = function (task, exec, done) { var args = ['clean'].concat(argUtil.getArgFlags()); // Add the file paths to the arguments. - task.files.forEach(function (files) { - for (var i = 0; i < files.src.length; i++) { - args.push(files.src[i]); - } + task.data.files.src.forEach(function (file) { + args.push(file); }); // Add callback diff --git a/lib/command_commit.js b/lib/command_commit.js index 5fc7827..cf279b5 100644 --- a/lib/command_commit.js +++ b/lib/command_commit.js @@ -36,10 +36,8 @@ module.exports = function (task, exec, done) { var options = argUtil.options; var args = ['commit'].concat(argUtil.getArgFlags()); - task.files.forEach(function (files) { - for (var i = 0; i < files.src.length; i++) { - args.push(files.src[i]); - } + task.data.files.src.forEach(function (file) { + args.push(file); }); args.push(done); diff --git a/lib/command_reset.js b/lib/command_reset.js index 12a8c15..ff0d7a3 100644 --- a/lib/command_reset.js +++ b/lib/command_reset.js @@ -29,13 +29,9 @@ module.exports = function (task, exec, done) { var options = argUtil.options; var args = ['reset'].concat(argUtil.getArgFlags()); - if (!options.mode) { - task.files.forEach(function (files) { - for (var i = 0; i < files.src.length; i++) { - args.push(files.src[i]); - } - }); - } + task.data.files.src.forEach(function (file) { + args.push(file); + }); // Add callback args.push(done); diff --git a/test/_common.js b/test/_common.js index eabe160..bae0019 100644 --- a/test/_common.js +++ b/test/_common.js @@ -12,13 +12,13 @@ var Task = (function () { return _.defaults(this.test.options, defaults); }; - Object.defineProperty(Task.prototype, 'files', { + Object.defineProperty(Task.prototype, 'data', { get: function () { - return [ - { + return { + files: { src: this.test.files } - ]; + }; } }); diff --git a/test/add_test.js b/test/add_test.js index 95d9834..88ee024 100644 --- a/test/add_test.js +++ b/test/add_test.js @@ -20,11 +20,11 @@ describe('add', function () { }; var files = [ - 'test.txt' + 'test.txt', 'b.txt' ]; new Test(command, options, files) - .expect(['add', '--force', 'test.txt']) + .expect(['add', '--force', 'test.txt', 'b.txt']) .run(done); });