paulmillr / chokidar

Minimal and efficient cross-platform file watching library
https://paulmillr.com
MIT License
11.05k stars 586 forks source link

Specific glob patter returns empty #1351

Closed jcharnley closed 2 months ago

jcharnley commented 2 months ago

weird but when i use a glob my watcher always returns empty if I only look for speific format only, ive just installed version 4 today so am not sure if this is a new thing?

const folderWatch = async (directoryPath) => { const watcher = chokidar.watch(["${directoryPath}/*/.otf","${directoryPath}/*/.key"], { ignored: (filePath) => /(^|[\/\\])\../.test(filePath), persistent: true, usePolling: true, interval: 3000, // Adjust the interval as needed ignoreInitial: true, awaitWriteFinish: { stabilityThreshold: 2000, pollInterval: 100, }, }); watcher .on('ready', () => { const watchedPaths = watcher.getWatched(); console.log('watchedPaths', watchedPaths); process.send({ type: 'online', message: 'Initial scan complete. Watcher is live' }); }) .on('add', addMsg) .on('addDir', (path) => console.log(Directory ${path} has been added)) .on('change', (path) => changeMsg(path, watcher)) .on('unlink', (path) => console.log(File ${path} has been removed)) .on('error', (error) => { console.log('Watcher error', error); })

however if i just watch the complete directoryPath it works, it has always worked but as these folders can be 100gbs of size and sometimes over network drives i thought it might be good to limit how many its listening to, i just need to know about new folders/files with key/otf formarts
like so

Screenshot 2024-09-13 at 16 20 58

Also am not sure my ignored is correct, it no longers accept a Regex only a String it seems @paulmillr thanks for the great library

if i take ignored out i still get a blank watcher - watchedPaths {}

Originally posted by @jcharnley in https://github.com/paulmillr/chokidar/issues/628#issuecomment-2349217001

paulmillr commented 2 months ago

We don't support globs since v4.

paulmillr commented 2 months ago

1350