Open ghost opened 6 years ago
Hi @POPCORNS1068,
The last two features actually are more likely based on the first one. But I'm concerned about the efficiency of scanning when the directory is too deep.
It did that in earlier versions of node-watch (<=0.3.x) and it's hard to go back now.
Anyway, PRs are welcome and I'd love to add the create
event if it is implemented other than scanning.
Maybe make them optional like the recursive
option?
Oops that was unintentional
That may be huge work :D Could you share your current workarounds?
For the initial scan, I used this snippet here (modified to create a tree instead of a list): https://stackoverflow.com/questions/5827612/node-js-fs-readdir-recursive-directory-search.
I made it add the found dirs/files to a tree and keep it updated with the change events (add updated dir/file into tree if it's not already in it, remove if it's removed)
As for the last one, since I already have a tree of files, when a remove event occurs for a directory, I remove (and report) that dir and it's contents in that tree, recursively.
I'm not that into js so that's I could come up with.
I'm going to leave it open to see if anyone upvote for this.
"Initial Scan" would be great feature!
I am also switching from chokidar
(because recursively watching on Windows locks all subdirectories so that they cannot be renamed or deleted), and I have similar feature requests:
readdirp
, with a counter to ensure the scan stops early when the directory tree is too deeprm -rf
by maintaining a list of all files in the directoryreaddirp
to find the directory contents whenever a new directory is created.I would very much like to see the points in the first post addressed, especially the third one would be a deal breaker for me, if a file is deleted and I don't get an event about that file I'd consider it a bug even.
I wanted to submit a PR with those missing features, but I ended up rewriting the whole thing, now it should do pretty much everything except for supporting symlinks, I'll leave a link to it here in case somebody here is interested: https://www.npmjs.com/package/watcher
I've been considering switching over from chokidar to this due to a few issues, and having 0 dependencies is actually somewhat appealing to me.
But I'm missing a few features:
Currently I have a few dirty workarounds for some of the things above, but it'd be nice if node-watch can have these built-in.