directory-walker
Advanced tools
Comparing version 1.1.0 to 1.2.0
@@ -9,4 +9,3 @@ // third-party dependencies | ||
events.EventEmitter.call(this); | ||
this.basedir = config.basedir; | ||
this.onFile = config.onFile; | ||
@@ -17,6 +16,7 @@ this.onDirectory = config.onDirectory; | ||
if (config.excludes) { | ||
this.excludes = {}; | ||
this._excludesMap = {}; | ||
for (var i = 0; i < config.excludes.length; i++) { | ||
var exclude = path.resolve(config.excludes[i]); | ||
this.excludes[exclude] = true; | ||
this._excludesMap[exclude] = true; | ||
} | ||
@@ -38,6 +38,3 @@ } | ||
DirectoryWalker.prototype.walk = function(dir) { | ||
// right before we read directory, we increment pending | ||
// right after directory is read, we decrement pending | ||
// when pending drops back to zero then we are down walking | ||
this.readdir(dir || this.basedir); | ||
this.visit(dir); | ||
}; | ||
@@ -49,2 +46,6 @@ | ||
DirectoryWalker.prototype.isExplicitExclude = function(path) { | ||
return this._excludesMap && this._excludesMap[path]; | ||
}; | ||
DirectoryWalker.prototype.visit = function(file, parent) { | ||
@@ -77,3 +78,3 @@ var self = this; | ||
var dir = path.resolve(dir); | ||
if (this.excludes && this.excludes[dir]) { | ||
if (this._excludesMap && this._excludesMap[dir]) { | ||
return; | ||
@@ -99,3 +100,3 @@ } | ||
var file = path.resolve(dir + '/' + files[i]); | ||
if (!this.excludes || !this.excludes[dir]) { | ||
if (!this._excludesMap || !this._excludesMap[dir]) { | ||
self.visit(file, dir); | ||
@@ -118,3 +119,3 @@ } | ||
var walker = new DirectoryWalker(options); | ||
walker.start(); | ||
walker.walk(options.basedir); | ||
} |
{ | ||
"name": "directory-walker", | ||
"description": "Directory walker", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"homepage": "https://github.com/philidem/node-directory-walker", | ||
@@ -6,0 +6,0 @@ "authors": [ |
3298
89