Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (this.state !== 'active') return this
// Close
this.log('debug', `close: ${this.path}`)
// Close our children
eachr(this.children, child => {
child.close(reason)
})
// Close watch listener
if (this.fswatcher != null) {
this.fswatcher.close()
this.fswatcher = null
} else {
fsUtil.unwatchFile(this.path)
}
// Updated state
if (reason === 'deleted') {
this.state = 'deleted'
} else {
this.state = 'closed'
}
// Emit our close event
this.log('debug', `watch closed because ${reason} on ${this.path}`)
this.emit('close', reason)
// Chain
return this
}