Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Set this sub group to execute in parallel
this.setConfig({ concurrency: 0 })
// So let's check if we are a directory
if (currentStat.isDirectory() === false) {
// If we are a file, lets simply emit the change event
this.log('debug', `watch emit update: ${this.path}`)
this.emit('change', 'update', this.path, currentStat, previousStat)
return done()
}
// We are a direcotry
// Chances are something actually happened to a child (rename or delete)
// and if we are the same, then we should scan our children to look for renames and deletes
fsUtil.readdir(this.path, (err, newFileRelativePaths) => {
// Error?
if (err) return done(err)
// Log
this.log('debug', `watch read dir: ${this.path}`, newFileRelativePaths)
// Find deleted files
eachr(this.children, (child, childFileRelativePath) => {
// Skip if the file still exists
if (newFileRelativePaths.indexOf(childFileRelativePath) !== -1) return
// Fetch full path
const childFileFullPath = pathUtil.join(
this.path,
childFileRelativePath
)
tasks.addTask(complete => {
readdir(this.cwd, (err, files) => {
if (err) return complete(err)
files.forEach(file => {
const filePath = join(this.cwd, file)
packages.forEach(key => {
const basename = file
.toLowerCase()
.split('.')
.slice(0, -1)
.join('.')
if (basename === key) {
const message = `Reading package file: ${filePath}`
tasks.addTask(message, complete => {
this.log('info', message)
CSON.readFile(filePath, (err, data) => {
if (err) return complete(err)