pathwatcher
Advanced tools
Comparing version 6.8.1 to 6.9.0
92
api.json
@@ -6,3 +6,3 @@ { | ||
"filename": "src/directory.coffee", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.8.1/src/directory.coffee#L13", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.9.0/src/directory.coffee#L13", | ||
"sections": [ | ||
@@ -35,3 +35,3 @@ { | ||
"sectionName": "Construction", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.8.1/src/directory.coffee#L26", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.9.0/src/directory.coffee#L26", | ||
"visibility": "Public", | ||
@@ -58,3 +58,3 @@ "summary": "Configures a new Directory instance, no files are accessed.", | ||
"sectionName": "Construction", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.8.1/src/directory.coffee#L51", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.9.0/src/directory.coffee#L51", | ||
"visibility": "Public", | ||
@@ -81,3 +81,3 @@ "summary": "Creates the directory on disk that corresponds to `::getPath()` if\nno such directory already exists.", | ||
"sectionName": "Event Subscription", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.8.1/src/directory.coffee#L73", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.9.0/src/directory.coffee#L73", | ||
"visibility": "Public", | ||
@@ -104,3 +104,3 @@ "summary": "Invoke the given callback when the directory's contents change.", | ||
"sectionName": "Directory Metadata", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.8.1/src/directory.coffee#L95", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.9.0/src/directory.coffee#L95", | ||
"visibility": "Public", | ||
@@ -119,3 +119,3 @@ "summary": "", | ||
"sectionName": "Directory Metadata", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.8.1/src/directory.coffee#L98", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.9.0/src/directory.coffee#L98", | ||
"visibility": "Public", | ||
@@ -134,3 +134,3 @@ "summary": "", | ||
"sectionName": "Directory Metadata", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.8.1/src/directory.coffee#L101", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.9.0/src/directory.coffee#L101", | ||
"visibility": "Public", | ||
@@ -149,3 +149,3 @@ "summary": "", | ||
"sectionName": "Directory Metadata", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.8.1/src/directory.coffee#L106", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.9.0/src/directory.coffee#L106", | ||
"visibility": "Public", | ||
@@ -164,3 +164,3 @@ "summary": "", | ||
"sectionName": "Directory Metadata", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.8.1/src/directory.coffee#L110", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.9.0/src/directory.coffee#L110", | ||
"visibility": "Public", | ||
@@ -179,3 +179,3 @@ "summary": "", | ||
"sectionName": "Directory Metadata", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.8.1/src/directory.coffee#L115", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.9.0/src/directory.coffee#L115", | ||
"visibility": "Public", | ||
@@ -188,3 +188,3 @@ "summary": "Return a {Boolean}, true if this {Directory} is the root directory\nof the filesystem, or false if it isn't. ", | ||
"sectionName": "Managing Paths", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.8.1/src/directory.coffee#L126", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.9.0/src/directory.coffee#L126", | ||
"visibility": "Public", | ||
@@ -203,3 +203,3 @@ "summary": "", | ||
"sectionName": "Managing Paths", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.8.1/src/directory.coffee#L132", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.9.0/src/directory.coffee#L132", | ||
"visibility": "Public", | ||
@@ -218,3 +218,3 @@ "summary": "", | ||
"sectionName": "Managing Paths", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.8.1/src/directory.coffee#L143", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.9.0/src/directory.coffee#L143", | ||
"visibility": "Public", | ||
@@ -233,3 +233,3 @@ "summary": "", | ||
"sectionName": "Managing Paths", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.8.1/src/directory.coffee#L148", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.9.0/src/directory.coffee#L148", | ||
"visibility": "Public", | ||
@@ -248,3 +248,3 @@ "summary": "", | ||
"sectionName": "Traversing", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.8.1/src/directory.coffee#L205", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.9.0/src/directory.coffee#L205", | ||
"visibility": "Public", | ||
@@ -263,3 +263,3 @@ "summary": "Traverse to the parent directory.", | ||
"sectionName": "Traversing", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.8.1/src/directory.coffee#L214", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.9.0/src/directory.coffee#L214", | ||
"visibility": "Public", | ||
@@ -286,3 +286,3 @@ "summary": "Traverse within this Directory to a child File. This method doesn't\nactually check to see if the File exists, it just creates the File object.", | ||
"sectionName": "Traversing", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.8.1/src/directory.coffee#L224", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.9.0/src/directory.coffee#L224", | ||
"visibility": "Public", | ||
@@ -309,3 +309,3 @@ "summary": "Traverse within this a Directory to a child Directory. This method\ndoesn't actually check to see if the Directory exists, it just creates the\nDirectory object.", | ||
"sectionName": "Traversing", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.8.1/src/directory.coffee#L230", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.9.0/src/directory.coffee#L230", | ||
"visibility": "Public", | ||
@@ -324,3 +324,3 @@ "summary": "Reads file entries in this directory from disk synchronously.", | ||
"sectionName": "Traversing", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.8.1/src/directory.coffee#L251", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.9.0/src/directory.coffee#L251", | ||
"visibility": "Public", | ||
@@ -355,3 +355,3 @@ "summary": "Reads file entries in this directory from disk asynchronously.", | ||
"sectionName": "Traversing", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.8.1/src/directory.coffee#L282", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.9.0/src/directory.coffee#L282", | ||
"visibility": "Public", | ||
@@ -385,3 +385,3 @@ "summary": "Determines if the given path (real or symbolic) is inside this\ndirectory. This method does not actually check if the path exists, it just\nchecks if the path is under this directory.", | ||
"filename": "src/file.coffee", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.8.1/src/file.coffee#L18", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.9.0/src/file.coffee#L18", | ||
"sections": [ | ||
@@ -418,3 +418,3 @@ { | ||
"sectionName": "Construction", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.8.1/src/file.coffee#L31", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.9.0/src/file.coffee#L31", | ||
"visibility": "Public", | ||
@@ -441,3 +441,3 @@ "summary": "Configures a new File instance, no files are accessed.", | ||
"sectionName": "Construction", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.8.1/src/file.coffee#L53", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.9.0/src/file.coffee#L53", | ||
"visibility": "Public", | ||
@@ -456,3 +456,3 @@ "summary": "Creates the file on disk that corresponds to `::getPath()` if no\nsuch file already exists.", | ||
"sectionName": "Event Subscription", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.8.1/src/file.coffee#L71", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.9.0/src/file.coffee#L71", | ||
"visibility": "Public", | ||
@@ -479,3 +479,3 @@ "summary": "Invoke the given callback when the file's contents change.", | ||
"sectionName": "Event Subscription", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.8.1/src/file.coffee#L80", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.9.0/src/file.coffee#L80", | ||
"visibility": "Public", | ||
@@ -502,3 +502,3 @@ "summary": "Invoke the given callback when the file's path changes.", | ||
"sectionName": "Event Subscription", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.8.1/src/file.coffee#L89", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.9.0/src/file.coffee#L89", | ||
"visibility": "Public", | ||
@@ -525,3 +525,3 @@ "summary": "Invoke the given callback when the file is deleted.", | ||
"sectionName": "Event Subscription", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.8.1/src/file.coffee#L102", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.9.0/src/file.coffee#L102", | ||
"visibility": "Public", | ||
@@ -564,3 +564,3 @@ "summary": "Invoke the given callback when there is an error with the watch.\nWhen your callback has been invoked, the file will have unsubscribed from\nthe file watches.", | ||
"sectionName": "File Metadata", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.8.1/src/file.coffee#L124", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.9.0/src/file.coffee#L124", | ||
"visibility": "Public", | ||
@@ -579,3 +579,3 @@ "summary": "", | ||
"sectionName": "File Metadata", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.8.1/src/file.coffee#L127", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.9.0/src/file.coffee#L127", | ||
"visibility": "Public", | ||
@@ -594,3 +594,3 @@ "summary": "", | ||
"sectionName": "File Metadata", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.8.1/src/file.coffee#L130", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.9.0/src/file.coffee#L130", | ||
"visibility": "Public", | ||
@@ -609,3 +609,3 @@ "summary": "", | ||
"sectionName": "File Metadata", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.8.1/src/file.coffee#L135", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.9.0/src/file.coffee#L135", | ||
"visibility": "Public", | ||
@@ -624,3 +624,3 @@ "summary": "", | ||
"sectionName": "File Metadata", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.8.1/src/file.coffee#L140", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.9.0/src/file.coffee#L140", | ||
"visibility": "Public", | ||
@@ -639,3 +639,3 @@ "summary": "", | ||
"sectionName": "File Metadata", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.8.1/src/file.coffee#L146", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.9.0/src/file.coffee#L146", | ||
"visibility": "Public", | ||
@@ -654,3 +654,3 @@ "summary": "Get the SHA-1 digest of this file", | ||
"sectionName": "File Metadata", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.8.1/src/file.coffee#L155", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.9.0/src/file.coffee#L155", | ||
"visibility": "Public", | ||
@@ -669,3 +669,3 @@ "summary": "Get the SHA-1 digest of this file", | ||
"sectionName": "File Metadata", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.8.1/src/file.coffee#L165", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.9.0/src/file.coffee#L165", | ||
"visibility": "Public", | ||
@@ -686,3 +686,3 @@ "summary": "Sets the file's character set encoding name.", | ||
"sectionName": "File Metadata", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.8.1/src/file.coffee#L176", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.9.0/src/file.coffee#L176", | ||
"visibility": "Public", | ||
@@ -701,3 +701,3 @@ "summary": "", | ||
"sectionName": "Managing Paths", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.8.1/src/file.coffee#L183", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.9.0/src/file.coffee#L183", | ||
"visibility": "Public", | ||
@@ -716,3 +716,3 @@ "summary": "", | ||
"sectionName": "Managing Paths", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.8.1/src/file.coffee#L190", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.9.0/src/file.coffee#L190", | ||
"visibility": "Public", | ||
@@ -731,3 +731,3 @@ "summary": "", | ||
"sectionName": "Managing Paths", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.8.1/src/file.coffee#L199", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.9.0/src/file.coffee#L199", | ||
"visibility": "Public", | ||
@@ -746,3 +746,3 @@ "summary": "", | ||
"sectionName": "Managing Paths", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.8.1/src/file.coffee#L211", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.9.0/src/file.coffee#L211", | ||
"visibility": "Public", | ||
@@ -755,3 +755,3 @@ "summary": "Return the {String} filename without any directory information. ", | ||
"sectionName": "Traversing", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.8.1/src/file.coffee#L219", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.9.0/src/file.coffee#L219", | ||
"visibility": "Public", | ||
@@ -764,3 +764,3 @@ "summary": "Return the {Directory} that contains this file. ", | ||
"sectionName": "Reading and Writing", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.8.1/src/file.coffee#L255", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.9.0/src/file.coffee#L255", | ||
"visibility": "Public", | ||
@@ -787,3 +787,3 @@ "summary": "Reads the contents of the file.", | ||
"sectionName": "Reading and Writing", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.8.1/src/file.coffee#L282", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.9.0/src/file.coffee#L282", | ||
"visibility": "Public", | ||
@@ -806,3 +806,3 @@ "summary": "", | ||
"sectionName": "Reading and Writing", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.8.1/src/file.coffee#L295", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.9.0/src/file.coffee#L295", | ||
"visibility": "Public", | ||
@@ -829,3 +829,3 @@ "summary": "Overwrites the file with the given text.", | ||
"sectionName": "Reading and Writing", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.8.1/src/file.coffee#L306", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.9.0/src/file.coffee#L306", | ||
"visibility": "Public", | ||
@@ -848,3 +848,3 @@ "summary": "", | ||
"sectionName": "Reading and Writing", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.8.1/src/file.coffee#L321", | ||
"srcUrl": "https://github.com/atom/node-pathwatcher/blob/v6.9.0/src/file.coffee#L321", | ||
"visibility": "Public", | ||
@@ -851,0 +851,0 @@ "summary": "Overwrites the file with the given text.", |
144
lib/main.js
(function() { | ||
var EventEmitter, HandleMap, HandleWatcher, PathWatcher, binding, fs, handleWatchers, path, | ||
__hasProp = {}.hasOwnProperty, | ||
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; | ||
var Emitter, HandleMap, HandleWatcher, PathWatcher, binding, fs, handleWatchers, path; | ||
@@ -10,3 +8,3 @@ binding = require('../build/Release/pathwatcher.node'); | ||
EventEmitter = require('events').EventEmitter; | ||
Emitter = require('event-kit').Emitter; | ||
@@ -17,16 +15,8 @@ fs = require('fs'); | ||
handleWatchers = new HandleMap; | ||
handleWatchers = null; | ||
binding.setCallback(function(event, handle, filePath, oldFilePath) { | ||
if (handleWatchers.has(handle)) { | ||
return handleWatchers.get(handle).onEvent(event, filePath, oldFilePath); | ||
} | ||
}); | ||
HandleWatcher = (function(_super) { | ||
__extends(HandleWatcher, _super); | ||
HandleWatcher = (function() { | ||
function HandleWatcher(path) { | ||
this.path = path; | ||
this.setMaxListeners(Infinity); | ||
this.emitter = new Emitter(); | ||
this.start(); | ||
@@ -52,11 +42,20 @@ } | ||
if (process.platform === 'darwin' && /\/\.Trash\//.test(filePath)) { | ||
_this.emit('change', 'delete', null); | ||
_this.emitter.emit('did-change', { | ||
event: 'delete', | ||
newFilePath: null | ||
}); | ||
return _this.close(); | ||
} else { | ||
_this.start(); | ||
return _this.emit('change', 'rename', filePath); | ||
return _this.emitter.emit('did-change', { | ||
event: 'rename', | ||
newFilePath: filePath | ||
}); | ||
} | ||
} else { | ||
_this.start(); | ||
return _this.emit('change', 'change', null); | ||
return _this.emitter.emit('did-change', { | ||
event: 'change', | ||
newFilePath: null | ||
}); | ||
} | ||
@@ -68,3 +67,6 @@ }); | ||
case 'delete': | ||
this.emit('change', 'delete', null); | ||
this.emitter.emit('did-change', { | ||
event: 'delete', | ||
newFilePath: null | ||
}); | ||
return this.close(); | ||
@@ -75,6 +77,14 @@ case 'unknown': | ||
default: | ||
return this.emit('change', event, filePath, oldFilePath); | ||
return this.emitter.emit('did-change', { | ||
event: event, | ||
newFilePath: filePath, | ||
oldFilePath: oldFilePath | ||
}); | ||
} | ||
}; | ||
HandleWatcher.prototype.onDidChange = function(callback) { | ||
return this.emitter.on('did-change', callback); | ||
}; | ||
HandleWatcher.prototype.start = function() { | ||
@@ -92,3 +102,3 @@ var troubleWatcher; | ||
HandleWatcher.prototype.closeIfNoListener = function() { | ||
if (this.listeners('change').length === 0) { | ||
if (this.emitter.getTotalListenerCount() === 0) { | ||
return this.close(); | ||
@@ -107,7 +117,5 @@ } | ||
})(EventEmitter); | ||
})(); | ||
PathWatcher = (function(_super) { | ||
__extends(PathWatcher, _super); | ||
PathWatcher = (function() { | ||
PathWatcher.prototype.isWatchingParent = false; | ||
@@ -122,2 +130,3 @@ | ||
this.path = filePath; | ||
this.emitter = new Emitter(); | ||
if (process.platform === 'win32') { | ||
@@ -142,3 +151,5 @@ stats = fs.statSync(filePath); | ||
this.onChange = (function(_this) { | ||
return function(event, newFilePath, oldFilePath) { | ||
return function(_arg) { | ||
var event, newFilePath, oldFilePath; | ||
event = _arg.event, newFilePath = _arg.newFilePath, oldFilePath = _arg.oldFilePath; | ||
switch (event) { | ||
@@ -154,10 +165,19 @@ case 'rename': | ||
} | ||
return _this.emit('change', event, newFilePath); | ||
return _this.emitter.emit('did-change', { | ||
event: event, | ||
newFilePath: newFilePath | ||
}); | ||
case 'child-rename': | ||
if (_this.isWatchingParent) { | ||
if (_this.path === oldFilePath) { | ||
return _this.onChange('rename', newFilePath); | ||
return _this.onChange({ | ||
event: 'rename', | ||
newFilePath: newFilePath | ||
}); | ||
} | ||
} else { | ||
return _this.onChange('change', ''); | ||
return _this.onChange({ | ||
event: 'change', | ||
newFilePath: '' | ||
}); | ||
} | ||
@@ -168,6 +188,12 @@ break; | ||
if (_this.path === newFilePath) { | ||
return _this.onChange('delete', null); | ||
return _this.onChange({ | ||
event: 'delete', | ||
newFilePath: null | ||
}); | ||
} | ||
} else { | ||
return _this.onChange('change', ''); | ||
return _this.onChange({ | ||
event: 'change', | ||
newFilePath: '' | ||
}); | ||
} | ||
@@ -177,3 +203,6 @@ break; | ||
if (_this.isWatchingParent && _this.path === newFilePath) { | ||
return _this.onChange('change', ''); | ||
return _this.onChange({ | ||
event: 'change', | ||
newFilePath: '' | ||
}); | ||
} | ||
@@ -183,3 +212,6 @@ break; | ||
if (!_this.isWatchingParent) { | ||
return _this.onChange('change', ''); | ||
return _this.onChange({ | ||
event: 'change', | ||
newFilePath: '' | ||
}); | ||
} | ||
@@ -189,7 +221,12 @@ } | ||
})(this); | ||
this.handleWatcher.on('change', this.onChange); | ||
this.disposable = this.handleWatcher.onDidChange(this.onChange); | ||
} | ||
PathWatcher.prototype.onDidChange = function(callback) { | ||
return this.emitter.on('did-change', callback); | ||
}; | ||
PathWatcher.prototype.close = function() { | ||
this.handleWatcher.removeListener('change', this.onChange); | ||
this.emitter.dispose(); | ||
this.disposable.dispose(); | ||
return this.handleWatcher.closeIfNoListener(); | ||
@@ -200,7 +237,14 @@ }; | ||
})(EventEmitter); | ||
})(); | ||
exports.watch = function(path, callback) { | ||
path = require('path').resolve(path); | ||
return new PathWatcher(path, callback); | ||
exports.watch = function(pathToWatch, callback) { | ||
if (handleWatchers == null) { | ||
handleWatchers = new HandleMap; | ||
binding.setCallback(function(event, handle, filePath, oldFilePath) { | ||
if (handleWatchers.has(handle)) { | ||
return handleWatchers.get(handle).onEvent(event, filePath, oldFilePath); | ||
} | ||
}); | ||
} | ||
return new PathWatcher(path.resolve(pathToWatch), callback); | ||
}; | ||
@@ -210,8 +254,10 @@ | ||
var watcher, _i, _len, _ref; | ||
_ref = handleWatchers.values(); | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
watcher = _ref[_i]; | ||
watcher.close(); | ||
if (handleWatchers != null) { | ||
_ref = handleWatchers.values(); | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
watcher = _ref[_i]; | ||
watcher.close(); | ||
} | ||
return handleWatchers.clear(); | ||
} | ||
return handleWatchers.clear(); | ||
}; | ||
@@ -222,6 +268,8 @@ | ||
paths = []; | ||
_ref = handleWatchers.values(); | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
watcher = _ref[_i]; | ||
paths.push(watcher.path); | ||
if (handleWatchers != null) { | ||
_ref = handleWatchers.values(); | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
watcher = _ref[_i]; | ||
paths.push(watcher.path); | ||
} | ||
} | ||
@@ -228,0 +276,0 @@ return paths; |
@@ -5,3 +5,3 @@ { | ||
"description": "Watch files and directories for changes", | ||
"version": "6.8.1", | ||
"version": "6.9.0", | ||
"licenses": [ | ||
@@ -40,3 +40,3 @@ { | ||
"emissary": "^1.3.2", | ||
"event-kit": "^1.0.0", | ||
"event-kit": "^2.1.0", | ||
"fs-plus": "^2.1", | ||
@@ -43,0 +43,0 @@ "grim": "^2.0.1", |
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
101825
1968
- Removedevent-kit@1.5.0(transitive)
- Removedgrim@1.5.0(transitive)
Updatedevent-kit@^2.1.0