Closed peter-olom closed 1 year ago
In attempting to watch specific file types, chokidar effectively stops watching all files.
To Reproduce:
import chokidar from "chokidar"; import path, { extname } from "path"; const WATCH_DIR = path.join(process.env.USERPROFILE ?? '', '/Documents'); console.log('@@@ Watching directory: ', WATCH_DIR); // Outputs the correct directory e.g C:\Users\username\Documents const watcher = chokidar.watch(WATCH_DIR, { //ignore all none documents ignored: path => !(['xlsx', 'docx', 'pdf', 'pptx', 'txt'].includes(extname(path).slice(1))), ignoreInitial: true, ignorePermissionErrors: true, }); watcher.on('all', (event, path) => { console.log('@@@', event, path); });
Expected behavior When I add or delete any file type in the list, an event is emitted.
Additional context If I remove the negation (!) in the ignored prop, then it ignores all the file types in the list.
Never mind this issue, I gave it a fresh look today and realized I could implement a white watchlist using glob patterns.
In attempting to watch specific file types, chokidar effectively stops watching all files.
To Reproduce:
Expected behavior When I add or delete any file type in the list, an event is emitted.
Additional context If I remove the negation (!) in the ignored prop, then it ignores all the file types in the list.