* Stops watching a file for changes. * @param {string} path The path to stop watching * @param {Function} [listener] Optional listener to remove
(path, listener)
| 996 | * @param {Function} [listener] Optional listener to remove |
| 997 | */ |
| 998 | unwatchFile(path, listener) { |
| 999 | const normalized = this.#normalizePath(path); |
| 1000 | const watcher = this[kStatWatchers].get(normalized); |
| 1001 | |
| 1002 | if (!watcher) { |
| 1003 | return; |
| 1004 | } |
| 1005 | |
| 1006 | if (listener) { |
| 1007 | watcher.removeListener('change', listener); |
| 1008 | } else { |
| 1009 | // Remove all listeners |
| 1010 | watcher.removeAllListeners('change'); |
| 1011 | } |
| 1012 | |
| 1013 | // If no more listeners, stop and remove the watcher |
| 1014 | if (watcher.hasNoListeners()) { |
| 1015 | watcher.stop(); |
| 1016 | this[kStatWatchers].delete(normalized); |
| 1017 | } |
| 1018 | } |
| 1019 | } |
| 1020 | |
| 1021 | module.exports = { |
nothing calls this directly
no test coverage detected