Comparing version 1.5.0 to 1.5.1
@@ -15,2 +15,6 @@ 'use strict'; | ||
// Threshold of duplicate path prefixes at which to start | ||
// consolidating going forward | ||
var consolidateThreshhold = 10; | ||
// Private function: Instantiates the fsevents interface | ||
@@ -38,3 +42,12 @@ | ||
var watchContainer; | ||
var parentPath = sysPath.dirname(watchPath); | ||
// If we've accumulated a substantial number of paths that | ||
// could have been consolidated by watching one directory | ||
// above the current one, create a watcher on the parent | ||
// path instead, so that we do consolidate going forward. | ||
if (couldConsolidate(parentPath)) { | ||
watchPath = parentPath; | ||
} | ||
var resolvedPath = sysPath.resolve(path); | ||
@@ -94,2 +107,21 @@ var hasSymlink = resolvedPath !== realPath; | ||
// Decide whether or not we should start a new higher-level | ||
// parent watcher | ||
function couldConsolidate(path) { | ||
var keys = Object.keys(FSEventsWatchers); | ||
var count = 0; | ||
for (var i = 0, len = keys.length; i < len; ++i) { | ||
var watchPath = keys[i]; | ||
if (watchPath.indexOf(path) === 0) { | ||
count++; | ||
if (count >= consolidateThreshhold) { | ||
return true; | ||
} | ||
} | ||
} | ||
return false; | ||
} | ||
// returns boolean indicating whether fsevents can be used | ||
@@ -96,0 +128,0 @@ function canUse() { |
{ | ||
"name": "chokidar", | ||
"description": "A neat wrapper around node.js fs.watch / fs.watchFile / fsevents.", | ||
"version": "1.5.0", | ||
"version": "1.5.1", | ||
"keywords": [ | ||
@@ -6,0 +6,0 @@ "fs", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
62001
1353