0.2.4 add reject to on error, removed console.log, some other cleanup and logging
parent
0d65514630
commit
233670ecbd
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@uci-utils/watcher",
|
||||
"version": "0.2.3",
|
||||
"version": "0.2.4",
|
||||
"description": "File System Watcher Class that emits events",
|
||||
"main": "src/watcher.js",
|
||||
"scripts": {
|
||||
|
|
|
@ -35,8 +35,9 @@ class Watcher extends Emitter {
|
|||
this._watcher = watch(opts.source,opts)
|
||||
this._watcher.on('error', error => {
|
||||
log.error({error:error, msg:'Watcher error'})
|
||||
reject({error:error, msg:'Watcher error'})
|
||||
})
|
||||
this._watcher.on('ready', () => {
|
||||
this._watcher.once('ready', () => {
|
||||
clearTimeout(readyTimeout)
|
||||
log.info('initial scan sucessful, ready to start')
|
||||
this._ready=true
|
||||
|
@ -44,13 +45,13 @@ class Watcher extends Emitter {
|
|||
resolve()
|
||||
})
|
||||
let readyTimeout = setTimeout(() =>{
|
||||
log.fatal({options:opts, timeout:READY_TIMEOUT, msg:'Timeout: unabled to complete initial scan'})
|
||||
log.fatal({options:opts, timeout:READY_TIMEOUT, msg:'Timeout: unable to complete initial scan'})
|
||||
reject('timeout during intial scan')
|
||||
},READY_TIMEOUT)
|
||||
}
|
||||
else {
|
||||
log.fatal('MUST provide a source directory(s) option to watch')
|
||||
reject('no source provided')
|
||||
reject('watching - no source provided')
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -63,6 +64,7 @@ class Watcher extends Emitter {
|
|||
}
|
||||
if (!this._watcher) await this.init(opts)
|
||||
if (this._ready) {
|
||||
log.debug({watching:this._watcher.getWatched(),msg:'initial files watched'})
|
||||
log.info(`now watching ${this.opts.source}`)
|
||||
this._watcher.removeAllListeners() // just in case
|
||||
this.watching = true
|
||||
|
@ -116,12 +118,9 @@ class Watcher extends Emitter {
|
|||
}
|
||||
|
||||
async getIgnoreLists(lists) {
|
||||
// console.log('ignore lists', lists)
|
||||
if (typeof lists === 'string') lists=[lists]
|
||||
let ignored = await ignores(lists)
|
||||
// console.log('==ignores from lists', ignored)
|
||||
this._ignored = [...this._ignored,...ignored]
|
||||
// console.log(this._ignored)
|
||||
}
|
||||
|
||||
addIgnore(ignore) {
|
||||
|
|
Loading…
Reference in New Issue