I need to add support for this feature in my application. My current implementation is very simple:
this.watcher.on("add", (pathName: string) => {
this.sendNotifyAction(new NotifyAction(PathEvent.Add, pathName));
}).on("change", (pathName: string) => {
this.sendNotifyAction(new NotifyAction(PathEvent.Change, pathName));
}).on("unlink", (pathName: string) => {
this.sendNotifyAction(new NotifyAction(PathEvent.Delete, pathName));
}).on("ready", () => {
this.sendReadinessNotification();
});
Now I want to have something like:
private acceptedFileExtensions: string[] = ['.txt', '.docx', '.xlx', ...]
And use this array of extensions inside Chokidar. Therefore, if the file in the observed directory has an extension from the list, send a notification; if not, do nothing.
I saw a similar question at https://stackoverflow.com/a/166186/16/16 , but this is not what I really need.
Filtering inside the callback functions does not look very good, but I see no other options. Please inform.
Thank.
source
share