From db315eae134c1e0d9d9b47531615b13c4abb9026 Mon Sep 17 00:00:00 2001 From: Vince Date: Tue, 16 Oct 2018 20:50:10 -0400 Subject: [PATCH] Added unwatchFile method for issue-551 --- src/filesystem/interface.js | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/filesystem/interface.js b/src/filesystem/interface.js index 0c6b331..c66dd71 100644 --- a/src/filesystem/interface.js +++ b/src/filesystem/interface.js @@ -17,6 +17,7 @@ var providers = require('../providers/index.js'); var Shell = require('../shell/shell.js'); var Intercom = require('../../lib/intercom.js'); var FSWatcher = require('../fs-watcher.js'); +//var unwatcher = require('../unwatcherFile.js'); var Errors = require('../errors.js'); var defaultGuidFn = require('../shared.js').guid; @@ -159,6 +160,27 @@ function FileSystem(options, callback) { 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 function wrappedGuidFn(context) { return function(callback) { @@ -347,7 +369,7 @@ function FileSystem(options, callback) { callback(error); } }; - + FileSystem.prototype.promises[methodName] = promisify(FileSystem.prototype[methodName].bind(fs)); });