Skip to content

Commit

Permalink
Merge pull request #63 from tschaub/empty-src
Browse files Browse the repository at this point in the history
Handle empty src list.
  • Loading branch information
tschaub committed Oct 22, 2014
2 parents d5ad24a + 73f9bf4 commit 1f27116
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
10 changes: 10 additions & 0 deletions test/lib/util.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit 1f27116

Please sign in to comment.