Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
tasks.addTask('check if the file still exists', complete => {
// Log
this.log(
'debug',
`watch evaluating on: ${this.path} [state: ${this.state}]`
)
// Check if this is still needed
if (this.state !== 'active') {
this.log('debug', `watch discarded on: ${this.path}`)
tasks.clearRemaining()
return complete()
}
// Check if the file still exists
fsUtil.exists(this.path, exists => {
// Apply local global property
previousStat = this.stat
// If the file still exists, then update the stat
if (exists === false) {
// Log
this.log('debug', `watch emit delete: ${this.path}`)
// Apply
this.stat = null
this.close('deleted')
this.emit('change', 'delete', this.path, null, previousStat)
// Clear the remaining tasks, as they are no longer needed
tasks.clearRemaining()
return complete()
function readFile(path, readFileComplete) {
// Log
me.log(
'debug',
`Feedr === reading [${feed.url}] on [${path}], checking exists`
)
// Check the the file exists
safefs.exists(path, function(exists) {
// Check it exists
if (!exists) {
// Log
me.log(
'debug',
`Feedr === reading [${feed.url}] on [${path}], it doesn't exist`
)
// Exit
readFileComplete()
return
}
// Log
me.log(
'debug',