Skip to content

Commit

Permalink
improve performance
Browse files Browse the repository at this point in the history
  • Loading branch information
weixin committed Feb 20, 2017
1 parent f11b761 commit 6bd3d82
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/gaze.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,8 @@ Gaze.prototype.relative = function (dir, unixify) {

// Adds files and dirs to watched
Gaze.prototype._addToWatched = function (files) {
var dirs = [];

for (var i = 0; i < files.length; i++) {
var file = files[i];
var filepath = path.resolve(this.options.cwd, file);
Expand All @@ -269,6 +271,13 @@ Gaze.prototype._addToWatched = function (files) {
if (file.slice(-1) === '/') { filepath += path.sep; }
helper.objectPush(this._watched, path.dirname(filepath) + path.sep, filepath);

dirs.push(dirname);
}

dirs = helper.unique(dirs);

for (var k = 0; k < dirs.length; k++) {
dirname = dirs[k];
// add folders into the mix
var readdir = fs.readdirSync(dirname);
for (var j = 0; j < readdir.length; j++) {
Expand All @@ -278,6 +287,7 @@ Gaze.prototype._addToWatched = function (files) {
}
}
}

return this;
};

Expand Down

0 comments on commit 6bd3d82

Please sign in to comment.