Comparing version 2.3.6 to 2.3.7
## History | ||
- v2.3.7 February 6, 2013 | ||
- Changed the `preferredMethod` option into `preferredMethods` which accepts an array, defaults to `['watch','watchFile']` | ||
- If the watch action fails at the eve level we will try again with the preferredMethods reversed | ||
- This solves [issue #31](https://github.com/bevry/watchr/issues/31) where watching of large files would fail | ||
- Changed the `interval` option to default to `5007` (recommended by node) instead of `100` as it was before | ||
- The `watch` method provides us with immediate notification of changes without utilising polling, however the `watch` method fails for large amounts of files, in which case we will fall back to the `watchFile` method that will use this option, if the option is too small we will be constantly polling the large amount of files for changes using up all the CPU and memory, hence the change into a larger increment which has no CPU and memory impact. | ||
- v2.3.6 February 6, 2013 | ||
@@ -4,0 +11,0 @@ - Fixed fallback when preferredMethod is `watchFile` |
@@ -59,6 +59,6 @@ // Generated by CoffeeScript 1.4.0 | ||
outputLog: false, | ||
interval: 100, | ||
interval: 5007, | ||
persistent: true, | ||
duplicateDelay: 1 * 1000, | ||
preferredMethod: 'watch', | ||
preferredMethods: null, | ||
ignorePaths: false, | ||
@@ -82,2 +82,3 @@ ignoreHiddenFiles: false, | ||
this.config = balUtil.extend({}, this.config); | ||
this.config.preferredMethods = ['watch', 'watchFile']; | ||
if (config.next != null) { | ||
@@ -130,4 +131,4 @@ if (next == null) { | ||
_Class.prototype.setup = function(config) { | ||
this.path = config.path; | ||
balUtil.extend(this.config, config); | ||
this.path = this.config.path; | ||
if (this.config.stat) { | ||
@@ -336,3 +337,7 @@ this.stat = this.config.stat; | ||
_this.emitSafe('change', 'create', childFileFullPath, childFileStat, null); | ||
return _this.watchChild(childFileFullPath, childFileRelativePath, childFileStat); | ||
return _this.watchChild({ | ||
fullPath: childFileFullPath, | ||
relativePath: childFileRelativePath, | ||
stat: childFileStat | ||
}); | ||
}); | ||
@@ -430,9 +435,9 @@ }); | ||
_Class.prototype.watchChild = function(fileFullPath, fileRelativePath, fileStat, next) { | ||
var config, me, _base; | ||
_Class.prototype.watchChild = function(opts, next) { | ||
var config, me, _base, _name; | ||
me = this; | ||
config = this.config; | ||
(_base = me.children)[fileRelativePath] || (_base[fileRelativePath] = watch({ | ||
path: fileFullPath, | ||
stat: fileStat, | ||
(_base = me.children)[_name = opts.relativePath] || (_base[_name] = watch({ | ||
path: opts.fullPath, | ||
stat: opts.stat, | ||
listeners: { | ||
@@ -444,4 +449,4 @@ 'log': me.bubbler('log'), | ||
changeType = args[0], path = args[1]; | ||
if (changeType === 'delete' && path === fileFullPath) { | ||
me.closeChild(fileRelativePath, 'deleted'); | ||
if (changeType === 'delete' && path === opts.fullPath) { | ||
me.closeChild(opts.relativePath, 'deleted'); | ||
} | ||
@@ -457,3 +462,3 @@ return me.bubble.apply(me, ['change'].concat(__slice.call(args))); | ||
duplicateDelay: config.duplicateDelay, | ||
preferredMethod: config.preferredMethod, | ||
preferredMethods: config.preferredMethods, | ||
ignorePaths: config.ignorePaths, | ||
@@ -464,3 +469,3 @@ ignoreHiddenFiles: config.ignoreHiddenFiles, | ||
})); | ||
return me.children[fileRelativePath]; | ||
return me.children[opts.relativePath]; | ||
}; | ||
@@ -491,7 +496,11 @@ | ||
}, | ||
action: function(fileFullPath, fileRelativePath, nextFile, fileStat) { | ||
action: function(fullPath, relativePath, nextFile, stat) { | ||
if (me.state !== 'active') { | ||
return nextFile(null, true); | ||
} | ||
return me.watchChild(fileFullPath, fileRelativePath, fileStat, function(err, watcher) { | ||
return me.watchChild({ | ||
fullPath: fullPath, | ||
relativePath: relativePath, | ||
stat: stat | ||
}, function(err, watcher) { | ||
return nextFile(err); | ||
@@ -556,14 +565,9 @@ }); | ||
}; | ||
if (config.preferredMethod === 'watch') { | ||
methodOne = methods.watch; | ||
methodTwo = methods.watchFile; | ||
} else { | ||
methodOne = methods.watchFile; | ||
methodTwo = methods.watch; | ||
} | ||
methodOne(function(err1, watching) { | ||
methodOne = me.config.preferredMethods[0]; | ||
methodTwo = me.config.preferredMethods[1]; | ||
methods[methodOne](function(err1, watching) { | ||
if (watching) { | ||
return complete(watching); | ||
} | ||
return methodTwo(function(err2, watching) { | ||
return methods[methodTwo](function(err2, watching) { | ||
if (watching) { | ||
@@ -663,3 +667,3 @@ return complete(watching); | ||
createWatcher = function(opts, next) { | ||
var listener, listeners, path, watcher; | ||
var attempt, listener, listeners, path, watcher; | ||
path = opts.path, listener = opts.listener, listeners = opts.listeners; | ||
@@ -690,4 +694,12 @@ if (opts.next != null) { | ||
} else { | ||
attempt = 0; | ||
watcher = new Watcher(opts, function(err) { | ||
return typeof next === "function" ? next(err, watcher) : void 0; | ||
if (!err || attempt !== 0) { | ||
return typeof next === "function" ? next(err, watcher) : void 0; | ||
} | ||
++attempt; | ||
watcher.log('debug', "Preferred method failed, trying methods in reverse order", err); | ||
return watcher.setup({ | ||
preferredMethods: watcher.config.preferredMethods.reverse() | ||
}).watch(); | ||
}); | ||
@@ -694,0 +706,0 @@ watchers[path] = watcher; |
{ | ||
"name": "watchr", | ||
"version": "2.3.6", | ||
"version": "2.3.7", | ||
"description": "Better file system watching for Node.js", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/bevry/watchr", |
@@ -22,3 +22,3 @@ ## Watchr: better file system watching for Node.js [![Build Status](https://secure.travis-ci.org/bevry/watchr.png?branch=master)](http://travis-ci.org/bevry/watchr) | ||
- `duplicateDelay` (optional, defaults to `1000`) sometimes events will fire really fast, this delay is set in place so we don't fire the same event within the timespan | ||
- `preferredMethod` (optional, defaults to `watch`) which watching method should try first? `watch` or `watchFile` | ||
- `preferredMethods` (optional, defaults to `['watch','watchFile']`) which order should we prefer our watching methods to be tried? | ||
- `ignorePaths` (optional, defaults to `false`) an array of full paths to ignore | ||
@@ -75,3 +75,3 @@ - `ignoreHiddenFiles` (optional, defaults to `false`) whether or not to ignored files which filename starts with a `.` | ||
// Close watchers after 10 seconds | ||
// Close watchers after 60 seconds | ||
setTimeout(function(){ | ||
@@ -83,3 +83,3 @@ var i; | ||
} | ||
},10*1000); | ||
},60*1000); | ||
} | ||
@@ -86,0 +86,0 @@ }); |
Sorry, the diff of this file is not supported yet
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
43379
687