From 7775f092b06439002b24326be7857de8719af9ea Mon Sep 17 00:00:00 2001 From: Ruslan Sagitov Date: Sun, 17 Aug 2014 17:27:57 +0400 Subject: [PATCH 1/3] Handle an empty list of source files --- lib/util.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/util.js b/lib/util.js index da85e92..46528f4 100644 --- a/lib/util.js +++ b/lib/util.js @@ -48,6 +48,9 @@ var filterPathsByTime = exports.filterPathsByTime = function(paths, time, * the comparison time. */ var anyNewer = exports.anyNewer = function(paths, time, override, callback) { + if (paths.length === 0) { + return callback(null, false); + } var complete = 0; function iterate() { fs.stat(paths[complete], function(err, stats) { From 884496939daf0762bbafbe8e215fa0db73eb57f6 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Tue, 21 Oct 2014 21:14:48 -0600 Subject: [PATCH 2/3] Asynconsistency --- lib/util.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/util.js b/lib/util.js index 46528f4..196d7d3 100644 --- a/lib/util.js +++ b/lib/util.js @@ -49,7 +49,10 @@ var filterPathsByTime = exports.filterPathsByTime = function(paths, time, */ var anyNewer = exports.anyNewer = function(paths, time, override, callback) { if (paths.length === 0) { - return callback(null, false); + process.nextTick(function() { + callback(null, false); + }); + return; } var complete = 0; function iterate() { From 73f9bf4bf23bdf31dd6f0a0cbb11d1dca255a491 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Tue, 21 Oct 2014 21:17:02 -0600 Subject: [PATCH 3/3] Test for empty src list --- test/lib/util.spec.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/lib/util.spec.js b/test/lib/util.spec.js index 6c5e1cc..e3147a8 100644 --- a/test/lib/util.spec.js +++ b/test/lib/util.spec.js @@ -182,6 +182,16 @@ describe('util', function() { }); }); + it('calls callback with false if no files are provided', function(done) { + util.anyNewer([], new Date(), nullOverride, function(err, newer) { + if (err) { + return done(err); + } + assert.isFalse(newer); + done(); + }); + }); + it('calls override with older file and time', function(done) { function override(filePath, time, include) { assert.equal(filePath, 'src/js/a.js');