Return empty hash from list if directory doesn't exist.
Conflicts: test/list.test.js
This commit is contained in:
@@ -76,6 +76,7 @@ MBTiles.registerProtocols = function(tilelive) {
|
||||
MBTiles.list = function(filepath, callback) {
|
||||
filepath = path.resolve(filepath);
|
||||
fs.readdir(filepath, function(err, files) {
|
||||
if (err && err.code === 'ENOENT') return callback(null, {});
|
||||
if (err) return callback(err);
|
||||
for (var result = {}, i = 0; i < files.length; i++) {
|
||||
var name = files[i].match(/^([\w-]+)\.mbtiles$/);
|
||||
|
||||
@@ -15,14 +15,9 @@ exports['list'] = function(beforeExit, assert) {
|
||||
var completed = false; beforeExit(function() { assert.ok(completed); });
|
||||
|
||||
MBTiles.list(fixtures.doesnotexist, function(err, list) {
|
||||
assert.ok(err);
|
||||
assert.ok(err.code.match(/^ENOENT/));
|
||||
|
||||
MBTiles.list(fixtures.doesnotexist, function(err, list) {
|
||||
completed = true;
|
||||
assert.ok(err);
|
||||
assert.ok(err.code.match(/^ENOENT/));
|
||||
});
|
||||
completed = true;
|
||||
assert.equal(err, null);
|
||||
assert.deepEqual(list, {});
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user