fix: catch and warn if remove watcher is called but no watcher was started.
master
Kebler Network System Administrator 2021-06-29 07:38:59 -07:00
parent 3d036ac7a0
commit f903ef7071
3 changed files with 78 additions and 76 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@uci-utils/watcher",
"version": "0.6.0",
"version": "0.6.1",
"description": "File System Watcher Class that emits events",
"main": "src/watcher.js",
"type": "module",

View File

@ -102,9 +102,11 @@ class Watcher extends Emitter {
}
remove() {
if (this._watcher) {
this.stop()
this._watcher.removeAllListeners()
delete (this._watcher)
} else log.warn('no watcher started nothing to remove')
this._ready = false
this.emit('ready', false)
}