Undo from finder/explorer does not report file events
Steps:
- setup parcel watcher according to docs, simply watching a folder [1]
- create a sub-folder in that watched folder
- create a file in that sub-folder
- from the finder (macOS) or explorer (Windows) delete the sub-folder
- => you get a delete event for that folder
- undo the operation from the finder / explorer
- => you get a create event but only for the folder, not for the files within
[1]
const watcher = require('@parcel/watcher');
const path = require('path');
async function main() {
// Subscribe to events
let subscription = await watcher.subscribe(process.cwd(), (err, events) => {
console.log(events);
});
}
main();
I think that's because when you delete a file, it only moves it to the trash. Then when you undo, it moves it back. So actually macOS delivers a rename event in that case. Not sure there's anything we could do about that short of traversing the entire directory ourselves. But you could also do that in user land - whenever a directory is created assume it might contain children. Do any other watcher libraries handle this?
Maybe rename events could be emitted by parcel watcher in case the underlying OS library supports it?
It also happens when we rename a folder which contains some files. Watcher fires a create event for the new folder only (no event are fired for the files inside)