Closed Janpot closed 4 months ago
I also reproduced this problem with @Janpot 's example but a little bit differently, I could get add
event when moving a dir, but no unlink
event.
We experience a very similar problem, but with folder deletion. We use chokidar
like this:
chokidar.watch([
'src/foo/**/file.json',
'src/bar/**/file.json'
], {
useFsEvents: false, // <-- THIS SOLVES THE PROBLEM
ignoreInitial: true,
}).on('all', (eventName, path) => console.log({eventName, path}))
When we delete foo
or bar
folders, neither unlink
nor unlinkDir
are emitted. The reason for that seems to be this line:
When a file patter contains a glob, it gets returned, so update is not reported.
The solution for us is to set useFsEvents: false
. It also seems to be used widely by other various libraries.
Describe the bug
When a folder is renamed and the original and new folder is part of a path that is covered by a glob that chokidar is watching, no events are fired.
Versions:
To Reproduce:
./hello/foo/file.txt
run
mv ./hello/foo ./hello/bar
Expected behavior
an
unlink
andadd
event is fired for the rename. (This does happen when usingusePolling
)