* Stops watching for changes on `filename`. * @param {string | Buffer | URL} filename * @param {() => any} [listener] * @returns {void}
(filename, listener)
| 3151 | * @returns {void} |
| 3152 | */ |
| 3153 | function unwatchFile(filename, listener) { |
| 3154 | const h = vfsState.handlers; |
| 3155 | if (h !== null) { |
| 3156 | if (h.unwatchFile(filename, listener)) return; |
| 3157 | } |
| 3158 | filename = getValidatedPath(filename); |
| 3159 | filename = pathModule.resolve(filename); |
| 3160 | const stat = statWatchers.get(filename); |
| 3161 | |
| 3162 | if (stat === undefined) return; |
| 3163 | const watchers = require('internal/fs/watchers'); |
| 3164 | if (typeof listener === 'function') { |
| 3165 | const beforeListenerCount = stat.listenerCount('change'); |
| 3166 | stat.removeListener('change', listener); |
| 3167 | if (stat.listenerCount('change') < beforeListenerCount) |
| 3168 | stat[watchers.kFSStatWatcherAddOrCleanRef]('clean'); |
| 3169 | } else { |
| 3170 | stat.removeAllListeners('change'); |
| 3171 | stat[watchers.kFSStatWatcherAddOrCleanRef]('cleanAll'); |
| 3172 | } |
| 3173 | |
| 3174 | if (stat.listenerCount('change') === 0) { |
| 3175 | stat.stop(); |
| 3176 | statWatchers.delete(filename); |
| 3177 | } |
| 3178 | } |
| 3179 | |
| 3180 | |
| 3181 | let splitRoot; |
nothing calls this directly
no test coverage detected