diff --git a/lib/util.js b/lib/util.js index da85e92..196d7d3 100644 --- a/lib/util.js +++ b/lib/util.js @@ -48,6 +48,12 @@ var filterPathsByTime = exports.filterPathsByTime = function(paths, time, * the comparison time. */ var anyNewer = exports.anyNewer = function(paths, time, override, callback) { + if (paths.length === 0) { + process.nextTick(function() { + callback(null, false); + }); + return; + } var complete = 0; function iterate() { fs.stat(paths[complete], function(err, stats) { 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');