From 7c1cea7f0a08c7163e988c8e65e3d65a7af7d971 Mon Sep 17 00:00:00 2001 From: Tom MacWright Date: Thu, 17 Feb 2011 10:08:21 -0500 Subject: [PATCH] Ignore dotfiles and dot-directories. TM #210 related. --- lib/carto/external.js | 4 ++++ test/external.test.js | 10 ++++++++++ 2 files changed, 14 insertions(+) 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'); + }); + }); +};