Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
watchMethod(method /* :MethodEnum */, next /* :ErrorCallback */) /* :void */ {
if (method === 'watch') {
// Check
if (fsUtil.watch == null) {
const err = new Error(
'watch method is not supported on this environment, fs.watch does not exist'
)
next(err)
return
}
// Watch
try {
this.fswatcher = fsUtil.watch(this.path, (...args) =>
this.listener({ method, args })
)
// must pass the listener here instead of doing fswatcher.on('change', opts.listener)
// as the latter is not supported on node 0.6 (only 0.8+)
} catch (err) {
next(err)
return
}
// Success
next()
return
} else if (method === 'watchFile') {
// Check
if (fsUtil.watchFile == null) {
const err = new Error(