Ignore dotfiles and dot-directories. TM #210 related.

This commit is contained in:
Tom MacWright 2011-02-17 10:08:21 -05:00
parent 60d519863e
commit 7c1cea7f0a
2 changed files with 14 additions and 0 deletions

View File

@ -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) {

View File

@ -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');
});
});
};