pathwatcher
Advanced tools
Comparing version 0.14.2 to 0.15.0
116
lib/main.js
@@ -33,19 +33,20 @@ (function() { | ||
HandleWatcher.prototype.onEvent = function(event, filePath, oldFilePath) { | ||
var detectRename, | ||
_this = this; | ||
var detectRename; | ||
switch (event) { | ||
case 'rename': | ||
this.close(); | ||
detectRename = function() { | ||
return fs.stat(_this.path, function(err) { | ||
if (err) { | ||
_this.path = filePath; | ||
_this.start(); | ||
return _this.emit('change', 'rename', filePath); | ||
} else { | ||
_this.start(); | ||
return _this.emit('change', 'change', null); | ||
} | ||
}); | ||
}; | ||
detectRename = (function(_this) { | ||
return function() { | ||
return fs.stat(_this.path, function(err) { | ||
if (err) { | ||
_this.path = filePath; | ||
_this.start(); | ||
return _this.emit('change', 'rename', filePath); | ||
} else { | ||
_this.start(); | ||
return _this.emit('change', 'change', null); | ||
} | ||
}); | ||
}; | ||
})(this); | ||
return setTimeout(detectRename, 100); | ||
@@ -101,4 +102,3 @@ case 'delete': | ||
function PathWatcher(filePath, callback) { | ||
var stats, watcher, _i, _len, _ref, | ||
_this = this; | ||
var stats, watcher, _i, _len, _ref; | ||
this.path = filePath; | ||
@@ -123,43 +123,45 @@ if (process.platform === 'win32') { | ||
} | ||
this.onChange = function(event, newFilePath, oldFilePath) { | ||
switch (event) { | ||
case 'rename': | ||
case 'change': | ||
case 'delete': | ||
if (event === 'rename') { | ||
_this.path = newFilePath; | ||
} | ||
if (typeof callback === 'function') { | ||
callback.call(_this, event, newFilePath); | ||
} | ||
return _this.emit('change', event, newFilePath); | ||
case 'child-rename': | ||
if (_this.isWatchingParent) { | ||
if (_this.path === oldFilePath) { | ||
return _this.onChange('rename', newFilePath); | ||
this.onChange = (function(_this) { | ||
return function(event, newFilePath, oldFilePath) { | ||
switch (event) { | ||
case 'rename': | ||
case 'change': | ||
case 'delete': | ||
if (event === 'rename') { | ||
_this.path = newFilePath; | ||
} | ||
} else { | ||
return _this.onChange('change', ''); | ||
} | ||
break; | ||
case 'child-delete': | ||
if (_this.isWatchingParent) { | ||
if (_this.path === newFilePath) { | ||
return _this.onChange('delete', null); | ||
if (typeof callback === 'function') { | ||
callback.call(_this, event, newFilePath); | ||
} | ||
} else { | ||
return _this.onChange('change', ''); | ||
} | ||
break; | ||
case 'child-change': | ||
if (_this.isWatchingParent && _this.path === newFilePath) { | ||
return _this.onChange('change', ''); | ||
} | ||
break; | ||
case 'child-create': | ||
if (!_this.isWatchingParent) { | ||
return _this.onChange('change', ''); | ||
} | ||
} | ||
}; | ||
return _this.emit('change', event, newFilePath); | ||
case 'child-rename': | ||
if (_this.isWatchingParent) { | ||
if (_this.path === oldFilePath) { | ||
return _this.onChange('rename', newFilePath); | ||
} | ||
} else { | ||
return _this.onChange('change', ''); | ||
} | ||
break; | ||
case 'child-delete': | ||
if (_this.isWatchingParent) { | ||
if (_this.path === newFilePath) { | ||
return _this.onChange('delete', null); | ||
} | ||
} else { | ||
return _this.onChange('change', ''); | ||
} | ||
break; | ||
case 'child-change': | ||
if (_this.isWatchingParent && _this.path === newFilePath) { | ||
return _this.onChange('change', ''); | ||
} | ||
break; | ||
case 'child-create': | ||
if (!_this.isWatchingParent) { | ||
return _this.onChange('change', ''); | ||
} | ||
} | ||
}; | ||
})(this); | ||
this.handleWatcher.on('change', this.onChange); | ||
@@ -203,2 +205,6 @@ } | ||
exports.File = require('./file'); | ||
exports.Directory = require('./directory'); | ||
}).call(this); |
{ | ||
"main": "./lib/main.js", | ||
"name": "pathwatcher", | ||
"readme": "README.md", | ||
"description": "Watch file events", | ||
"version": "0.14.2", | ||
"version": "0.15.0", | ||
"licenses": [ | ||
@@ -22,3 +21,3 @@ { | ||
"scripts": { | ||
"prepublish": "grunt clean coffee lint", | ||
"prepublish": "grunt prepublish", | ||
"test": "grunt test" | ||
@@ -28,7 +27,7 @@ }, | ||
"grunt": "~0.4.1", | ||
"grunt-contrib-coffee": "~0.6.6", | ||
"grunt-contrib-coffee": "~0.9.0", | ||
"grunt-cli": "~0.1.7", | ||
"grunt-shell": "~0.2.2", | ||
"coffee-script": "~1.6.2", | ||
"jasmine-focused": "~0.15.0", | ||
"jasmine-tagged": ">=1.1 <2.0", | ||
"rimraf": "~2.2.0", | ||
@@ -41,4 +40,9 @@ "node-cpplint": "~0.1.5", | ||
"bindings": "~1.1.0", | ||
"nan": "0.8.0" | ||
"nan": "0.8.0", | ||
"q": "~1.0.0", | ||
"emissary": "1.x", | ||
"underscore-plus": "~1.x", | ||
"fs-plus": "~2.x", | ||
"async": "~0.2.10" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
# Path Watcher Node Module | ||
# Path Watcher Node Module [![Build Status](https://travis-ci.org/atom/node-pathwatcher.png?branch=master)](https://travis-ci.org/atom/node-pathwatcher) | ||
@@ -12,4 +12,3 @@ ## Installing | ||
* Clone the repository | ||
* Run `npm install` | ||
* Run `grunt` to compile the CoffeeScript and native code | ||
* Run `npm install` to install the dependencies | ||
* Run `npm test` to run the specs | ||
@@ -16,0 +15,0 @@ |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
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
46474
18
499
7
38
3
2
+ Addedasync@~0.2.10
+ Addedemissary@1.x
+ Addedfs-plus@~2.x
+ Addedq@~1.0.0
+ Addedunderscore-plus@~1.x
+ Addedasync@0.2.101.5.2(transitive)
+ Addedbalanced-match@1.0.2(transitive)
+ Addedbrace-expansion@1.1.11(transitive)
+ Addedconcat-map@0.0.1(transitive)
+ Addedd@0.1.11.0.2(transitive)
+ Addedemissary@1.3.3(transitive)
+ Addedes5-ext@0.10.64(transitive)
+ Addedes6-iterator@0.1.32.0.3(transitive)
+ Addedes6-symbol@2.0.13.1.4(transitive)
+ Addedes6-weak-map@0.1.4(transitive)
+ Addedesniff@2.0.1(transitive)
+ Addedevent-emitter@0.3.5(transitive)
+ Addedext@1.7.0(transitive)
+ Addedfs-plus@2.10.1(transitive)
+ Addedfs.realpath@1.0.0(transitive)
+ Addedglob@7.2.3(transitive)
+ Addedinflight@1.0.6(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedminimatch@3.1.2(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedmixto@1.0.0(transitive)
+ Addedmkdirp@0.5.6(transitive)
+ Addednext-tick@1.1.0(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedpath-is-absolute@1.0.1(transitive)
+ Addedproperty-accessors@1.1.3(transitive)
+ Addedq@1.0.1(transitive)
+ Addedrimraf@2.7.1(transitive)
+ Addedtype@2.7.3(transitive)
+ Addedunderscore@1.13.7(transitive)
+ Addedunderscore-plus@1.7.0(transitive)
+ Addedwrappy@1.0.2(transitive)