paulmillr / chokidar

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

MacOS inconsistent eventing, Raw event fires but Change does not when watched dir case is incorrect. #1250

Closed nickharris closed 4 months ago

nickharris commented 1 year ago

Describe the bug

A clear and concise description of what the bug is.

Versions (please complete the following information):

1.

const chokidar = require('chokidar');

// Initialize watcher.
const watcher = chokidar.watch(process.cwd().toLowerCase(), {
  ignored: /(^|[\/\\])\../, // ignore dotfiles
  persistent: true  
});             

// Something to use when events are received.
const log = console.log.bind(console);

// Add event listeners.
watcher
  .on('add', path => log(`File ${path} has been added`))
  .on('change', path => log(`File ${path} has been changed`))
  .on('unlink', path => log(`File ${path} has been removed`))
  .on('ready', () => log('Initial scan complete. Ready for changes '))
  .on('raw', (event, path, details) => { // internal
    log('Raw event info:', event, path, details);
  });
  1. run the script above
  2. modify the content of a file in the directory
  3. Observe only the Raw event is fired.
  4. terminate the node process running the script
  5. Remove toLowerCase from the script
  6. run the script again
  7. modify the the file
  8. observe both change and raw events are fired.

Most valuable could be one or more test cases for test.js to demonstrate the problem.

Expected behavior when the watched dir on MacOS has incorrect case only the Raw event is fired. When the watched dir has the correct case both Raw and Changed are fired. Looks like change event has stricter case sensitive implementation. I would expect Raw and Changed to be consistent either both fire or both don't.

Additional context Add any other context about the problem here. Optionally nice to know what project you are working on.

nicolopadovan commented 3 months ago

I have the same problem on MacOS on file creation.