I am looking to view a folder using nodejs Chokidar I only want to keep track of additions, delete xml files. I am new to Chokidar and cannot understand. I tried setting Chokidar ignore to match all lines that end in .xml, but it looks like Chokidar ignore accepts a negative expression
Even the example below does not work
watcher = chokidar.watch(watcherFolder, {
ignored: /[^l]$,
persistent: true,
ignoreInitial: true,
alwaysState: true}
);
Is there a way to do this or do I need to add a filter to the callback function?
watcher.on('add', function(path) {
if (!/\.xml$/i.test(path)) { return; }
console.log('chokidar: add: ' + path);
});
watcher.on('unlink', function(path) {
if (!/\.xml$/i.test(path)) { return; }
console.log('chokidar: unlink: ' + path);
});
watcher.on('change', function(path) {
if (!/\.xml$/i.test(path)) { return; }
console.log('chokidar: change: ' + path);
});
source
share