Added unwatchFile method for issue-551

This commit is contained in:
Vince 2018-10-16 20:50:10 -04:00
parent 7c16490e25
commit db315eae13
1 changed files with 23 additions and 1 deletions

View File

@ -17,6 +17,7 @@ var providers = require('../providers/index.js');
var Shell = require('../shell/shell.js'); var Shell = require('../shell/shell.js');
var Intercom = require('../../lib/intercom.js'); var Intercom = require('../../lib/intercom.js');
var FSWatcher = require('../fs-watcher.js'); var FSWatcher = require('../fs-watcher.js');
//var unwatcher = require('../unwatcherFile.js');
var Errors = require('../errors.js'); var Errors = require('../errors.js');
var defaultGuidFn = require('../shared.js').guid; var defaultGuidFn = require('../shared.js').guid;
@ -159,6 +160,27 @@ function FileSystem(options, callback) {
return watcher; return watcher;
}; };
this.unwatchFile = function(filename, listener) {
if(isNullPath(filename)) {
throw new Error('Path must be a string without null bytes.');
}
listener = listener || nop;
if(listener == nop){
this.removeAllListeners();
}
else{
this.off('change', listener);
}
/*var unwatch = new unwatchFile();
if(listener == nop){
unwatch.removeListeners();
}
else{
unwatch.removeSingleListener(listener);
}*/
};
// Deal with various approaches to node ID creation // Deal with various approaches to node ID creation
function wrappedGuidFn(context) { function wrappedGuidFn(context) {
return function(callback) { return function(callback) {
@ -347,7 +369,7 @@ function FileSystem(options, callback) {
callback(error); callback(error);
} }
}; };
FileSystem.prototype.promises[methodName] = promisify(FileSystem.prototype[methodName].bind(fs)); FileSystem.prototype.promises[methodName] = promisify(FileSystem.prototype[methodName].bind(fs));
}); });