Comparing version 2.4.2 to 2.4.3
@@ -296,2 +296,12 @@ // Generated by CoffeeScript 1.6.2 | ||
this.log('debug', "watch event triggered on " + this.path + ":", args); | ||
if (args[0] === 'change' && this.children[args[1]]) { | ||
return (function() { | ||
var childFileRelativePath, childFileWatcher; | ||
childFileRelativePath = args[1]; | ||
childFileWatcher = _this.children[args[1]]; | ||
_this.log('debug', 'forwarding initial change detection to child:', childFileRelativePath, 'via:', fileFullPath); | ||
return childFileWatcher.listener('change', '.'); | ||
})(); | ||
} | ||
isTheSame = function() { | ||
@@ -316,83 +326,56 @@ if ((currentStat != null) && (previousStat != null)) { | ||
return safefs.readdir(fileFullPath, function(err, newFileRelativePaths) { | ||
var createdFiles, deletedFiles, tasks; | ||
if (err) { | ||
return _this.emit('error', err); | ||
} | ||
deletedFiles = []; | ||
createdFiles = []; | ||
tasks = new TaskGroup().setConfig({ | ||
concurrency: 0 | ||
}).once('complete', function() { | ||
var childFileRelativePath, childFileWatcher, eventName; | ||
if (typeChecker.isString(args[0]) && args[1] === null) { | ||
eachr(_this.children, function(childFileWatcher, childFileRelativePath) { | ||
if (__indexOf.call(newFileRelativePaths, childFileRelativePath) < 0) { | ||
return; | ||
} | ||
if (!childFileWatcher) { | ||
return; | ||
} | ||
_this.log('debug', 'forwarding extensive change detection to child:', childFileRelativePath, 'via:', fileFullPath); | ||
childFileWatcher.listener('change', '.'); | ||
}); | ||
} | ||
eachr(_this.children, function(childFileWatcher, childFileRelativePath) { | ||
var childFileFullPath; | ||
eventName = args[0], childFileRelativePath = args[1]; | ||
if (!typeChecker.isString(eventName)) { | ||
if (__indexOf.call(newFileRelativePaths, childFileRelativePath) >= 0) { | ||
return; | ||
} | ||
if (eventName !== 'change') { | ||
childFileFullPath = pathUtil.join(fileFullPath, childFileRelativePath); | ||
if (_this.isIgnoredPath(childFileFullPath)) { | ||
_this.log('debug', 'ignored delete:', childFileFullPath, 'via:', fileFullPath); | ||
return; | ||
} | ||
_this.log('debug', 'determined child file change:', childFileRelativePath, 'via:', fileFullPath); | ||
if (__indexOf.call(deletedFiles, childFileRelativePath) >= 0 || __indexOf.call(createdFiles, childFileRelativePath) >= 0) { | ||
_this.log('debug', 'that had already been taken care of:', childFileRelativePath, 'via:', fileFullPath); | ||
_this.log('debug', 'determined delete:', childFileFullPath, 'via:', fileFullPath); | ||
_this.closeChild(childFileRelativePath, 'deleted'); | ||
}); | ||
return eachr(newFileRelativePaths, function(childFileRelativePath) { | ||
var childFileFullPath; | ||
if (_this.children[childFileRelativePath] != null) { | ||
return; | ||
} | ||
childFileWatcher = _this.children[childFileRelativePath]; | ||
if (!childFileWatcher) { | ||
_this.log('debug', 'but had no watchr for the child file:', childFileRelativePath, 'via:', fileFullPath); | ||
_this.children[childFileRelativePath] = false; | ||
childFileFullPath = pathUtil.join(fileFullPath, childFileRelativePath); | ||
if (_this.isIgnoredPath(childFileFullPath)) { | ||
_this.log('debug', 'ignored create:', childFileFullPath, 'via:', fileFullPath); | ||
return; | ||
} | ||
_this.log('debug', 'forwarding child file change onto child watcher:', childFileRelativePath, 'via:', fileFullPath); | ||
return childFileWatcher.listener('change', '.'); | ||
}); | ||
eachr(_this.children, function(childFileWatcher, childFileRelativePath) { | ||
return tasks.addTask(function(complete) { | ||
var childFileFullPath; | ||
if (__indexOf.call(newFileRelativePaths, childFileRelativePath) >= 0) { | ||
return complete(); | ||
return safefs.stat(childFileFullPath, function(err, childFileStat) { | ||
if (err) { | ||
return; | ||
} | ||
childFileFullPath = pathUtil.join(fileFullPath, childFileRelativePath); | ||
if (_this.isIgnoredPath(childFileFullPath)) { | ||
_this.log('debug', 'ignored delete:', childFileFullPath, 'via:', fileFullPath); | ||
return complete(); | ||
} | ||
_this.log('debug', 'determined delete:', childFileFullPath, 'via:', fileFullPath); | ||
_this.closeChild(childFileRelativePath, 'deleted'); | ||
deletedFiles.push(childFileRelativePath); | ||
return complete(); | ||
}); | ||
}); | ||
eachr(newFileRelativePaths, function(childFileRelativePath) { | ||
return tasks.addTask(function(complete) { | ||
var childFileFullPath; | ||
if (_this.children[childFileRelativePath] != null) { | ||
return complete(); | ||
} | ||
_this.children[childFileRelativePath] = false; | ||
childFileFullPath = pathUtil.join(fileFullPath, childFileRelativePath); | ||
if (_this.isIgnoredPath(childFileFullPath)) { | ||
_this.log('debug', 'ignored create:', childFileFullPath, 'via:', fileFullPath); | ||
return complete(); | ||
} | ||
return safefs.stat(childFileFullPath, function(err, childFileStat) { | ||
if (err) { | ||
_this.emit('error', err); | ||
return complete(); | ||
} | ||
_this.log('debug', 'determined create:', childFileFullPath, 'via:', fileFullPath); | ||
_this.emitSafe('change', 'create', childFileFullPath, childFileStat, null); | ||
_this.watchChild({ | ||
fullPath: childFileFullPath, | ||
relativePath: childFileRelativePath, | ||
stat: childFileStat | ||
}); | ||
createdFiles.push(childFileRelativePath); | ||
return complete(); | ||
_this.log('debug', 'determined create:', childFileFullPath, 'via:', fileFullPath); | ||
_this.emitSafe('change', 'create', childFileFullPath, childFileStat, null); | ||
_this.watchChild({ | ||
fullPath: childFileFullPath, | ||
relativePath: childFileRelativePath, | ||
stat: childFileStat | ||
}); | ||
}); | ||
}); | ||
return tasks.run(); | ||
}); | ||
@@ -399,0 +382,0 @@ } |
{ | ||
"name": "watchr", | ||
"version": "2.4.2", | ||
"version": "2.4.3", | ||
"description": "Better file system watching for Node.js", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/bevry/watchr", |
36229
716