paulmillr / chokidar

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

Array of absolute files does not work #1366

Open luketych opened 3 weeks ago

luketych commented 3 weeks ago

"chokidar": "^4.0.1", node --version > v20.11.0 macOSX Sonoma 14.6.1

  const tmp = [
    "/Users/me/Dev/file_a.test.js",
    "/Users/me/Dev/file_b.test.js",
  ]

  const watcher = chokidar.watch(tmp, { persistent: true });

  watcher.on('change', async (filePath) => {
    console.log(`File changed: ${filePath}`);
  });

The above does not work.

  const tmp = [
    "./file_a.test.js",
    "./file_b.test.js",
  ]

  const watcher = chokidar.watch(tmp, { persistent: true });

  watcher.on('change', async (filePath) => {
    console.log(`File changed: ${filePath}`);
  });

However, if things are relative then they work.

  const tmp = "/Users/me/Dev/file_a.test.js"

  const watcher = chokidar.watch(tmp, { persistent: true });

  watcher.on('change', async (filePath) => {
    console.log(`File changed: ${filePath}`);
  });

This works as well.

43081j commented 3 weeks ago

this is a strange one

I'm seeing it happen more than in your example. whether I watch relative paths or not, an array of paths in one directory seems to always fail and only watch one path (when watching two paths at least)

this seems like a fairly bad bug if it happens for other people but I'm struggling to track down why its happening

if I watch a path containing two files, I get events fine for them both. if I watch the two files directly, I only get events for one.