Skip to content

Commit

Permalink
Filter out node_modules as early as possible
Browse files Browse the repository at this point in the history
  • Loading branch information
pahen committed Aug 17, 2016
1 parent 33dad4f commit 85fea62
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions lib/tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ class Tree {
requireConfig: this.config.requireConfig,
webpackConfig: this.config.webpackConfig,
visited: visited,
filter: (path) => {
return this.config.includeNpm || path.indexOf('node_modules') < 0;
}
filter: this.filterPath.bind(this)
}));
});

Expand All @@ -66,6 +64,15 @@ class Tree {
return tree;
}

/**
* Filter out some paths from found files
* @param {String} path
* @return {Boolean}
*/
filterPath(path) {
return this.config.includeNpm || path.indexOf('node_modules') < 0;
}

/**
* Get directories from the source paths
* @return {Promise} resolved with an array of directories
Expand Down Expand Up @@ -97,7 +104,7 @@ class Tree {
}

walk.sync(srcPath, (filePath, stat) => {
if (!stat.isFile()) {
if (!this.filterPath(filePath) || !stat.isFile()) {
return;
}

Expand Down

0 comments on commit 85fea62

Please sign in to comment.