Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Array of absolute files does not work #1366

Open
luketych opened this issue Sep 26, 2024 · 1 comment
Open

Array of absolute files does not work #1366

luketych opened this issue Sep 26, 2024 · 1 comment

Comments

@luketych
Copy link

"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
Copy link
Collaborator

43081j commented Sep 27, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants