diff options
-rw-r--r-- | doc/api/fs.md | 7 | ||||
-rw-r--r-- | lib/fs.js | 5 | ||||
-rw-r--r-- | test/parallel/test-fs-watch.js | 1 |
3 files changed, 13 insertions, 0 deletions
diff --git a/doc/api/fs.md b/doc/api/fs.md index 69138b6ac4..bf4261c15c 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -329,6 +329,13 @@ added: v0.5.8 Emitted when an error occurs while watching the file. +### Event: 'close' +<!-- YAML +added: REPLACEME +--> + +Emitted when the watcher stops watching for changes. + ### watcher.close() <!-- YAML added: v0.5.8 @@ -1387,8 +1387,13 @@ FSWatcher.prototype.close = function() { return; } this._handle.close(); + process.nextTick(emitCloseNT, this); }; +function emitCloseNT(self) { + self.emit('close'); +} + fs.watch = function(filename, options, listener) { if (typeof options === 'function') { listener = options; diff --git a/test/parallel/test-fs-watch.js b/test/parallel/test-fs-watch.js index 94a81799e5..ffa82e52c7 100644 --- a/test/parallel/test-fs-watch.js +++ b/test/parallel/test-fs-watch.js @@ -54,6 +54,7 @@ for (const testCase of cases) { } assert.fail(err); }); + watcher.on('close', common.mustCall()); watcher.on('change', common.mustCall(function(eventType, argFilename) { if (interval) { clearInterval(interval); |