Consider the following instruction:
chokidar.watch('src/*.js').on('add', (event, path) => {
console.log(event, path);
});
This will in fact trigger the "on add" call as many times as there are files to monitor, as chokidar treats its own file discover as if it's a filesystem "file came into existence" event, which seems quite wrong.
Rather, the add, change, unlink, addDir, and unlinkDir events should not fire until after ready, unless the user specifies they want this counter-intuitive behaviour through some options override (like having to explicitly set { waitForReady: false })
ignoreInitial: true
That should probably be made a default, rather than defaulting to false.
But until then, this option should be prominently mentioned early in the README.md as a "be aware of the following behaviour, because it can lead to a crazy bad time if you don't either set this to true, or wait for ready".
I think it should default to true
Most helpful comment
ignoreInitial: true