var watcher = chokidar.watch(['elm-package.json', (1)
'elm-stuff/exact-dependencies.json',
'**/*.elm'], {
cwd: process.cwd(),
persistent: true,
ignoreInitial: false,
followSymlinks: false,
atomic: false
});
watcher.on("raw", function(event, file, details) { (2)
var relFile = path.relative(process.cwd(), file);
var sourceDirs = getSourceDirs(process.cwd());
if(relFile === "elm-stuff/exact-dependencies.json") {
if ( event === "modified") {
parseAllPackageSources(); (3)
}
if (event === "deleted") {
sendAstMsg({
type: "packagesDeleted"
});
}
}
if (isSourceFile(sourceDirs, file) && event === "modified") {
parseAndSend(file); (4)
}
if (isSourceFile(sourceDirs, file) && event === "deleted") {
sendAstMsg({
file: file,
type: "deleted"
});
}
if (isSourceFile(sourceDirs, file) && event === "moved") {
if (fileExists(file)) {
parseAndSend(file);
} else {
sendAstMsg({
file: file,
type: "deleted"
});
}
}
});
elmGlobals.watcher = watcher;
}