diff --git a/lib/carto/external.js b/lib/carto/external.js index 7cb0ffa..49ca6ac 100644 --- a/lib/carto/external.js +++ b/lib/carto/external.js @@ -124,6 +124,8 @@ External.prototype.findOneByExtension = function(ext, callback) { this.findByExtension(ext, cb); } +// Find a file by extension in `this.path()`. +// Ignores .directories and .files External.prototype.findByExtension = function(ext, callback) { var running = 0; var found = []; @@ -138,6 +140,8 @@ External.prototype.findByExtension = function(ext, callback) { i; } files.forEach(function(file) { + // Ignore dotfiles and dot-directories + if (file[0] === '.') return; running++; file = path.join(dir, file); fs.stat(file, function(err, stats) { diff --git a/test/external.test.js b/test/external.test.js index fb606db..2c3f1f4 100644 --- a/test/external.test.js +++ b/test/external.test.js @@ -75,3 +75,13 @@ exports['test External with remote KML file'] = function(beforeExit) { helper.md5File(external.path(), 'f8aea6d693a48dabdc7ea3586cce57f7', context); }); }; + +exports['test External with DS_Store'] = function(beforeExit) { + new External(env, 'http://tilemill-testing.s3.amazonaws.com/carto/station_circles_bad.zip') + .on('complete', function(external) { + assert.ok(external instanceof External); + external.findDataFile(function(err, file) { + assert.eql('station_circles.shp', path.basename(file), 'The non-dot file was chosen'); + }); + }); +};