paulmillr / chokidar

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

Watching based on glob triggers on irrelevant files #1290

Closed jeremyben-meir closed 2 months ago

jeremyben-meir commented 11 months ago

Describe the bug

I want to scan my entire filesystem and check for changes only in .txt files. However, I am seeing changes in a bunch of non-txt files.

Versions (please complete the following information):

To Reproduce:

test.ts

var chokidar = require('chokidar');
const watcher = chokidar.watch('/**/*.txt', {
  persistent: true,
  ignoreInitial: true,
});
watcher.on('change', function (path: string) {
  console.log('File', path, 'has been changed');
});

Output:

File /var/db/diagnostics/Persist/0000000000002a33.tracev3 has been changed
File /var/folders/__/adf2kf994fqg8oinfhxle9fje0000fv/C/mds/mdsObject.db has been changed
File /var/folders/__/adf2kf994fqg8oinfhxle9fje0000fv/C/mds/mdsDirectory.db has been changed
...

Expected behavior I expect to see only changes in .txt files. This output would be reasonable:

File /path0/to/test0.txt has been changed
File /path0/to/test1.txt has been changed
File /path1/to/test0.txt has been changed
File /path1/to/test0.txt has been changed
...

Thanks!