yuanchuan / node-watch

A wrapper and enhancements for fs.watch
https://npm.im/node-watch
MIT License
340 stars 44 forks source link

A few feature requests #58

Open ghost opened 6 years ago

ghost commented 6 years ago

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.

yuanchuan commented 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.

ghost commented 6 years ago

Maybe make them optional like the recursive option?

ghost commented 6 years ago

Oops that was unintentional

yuanchuan commented 6 years ago

That may be huge work :D Could you share your current workarounds?

ghost commented 6 years ago

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.

yuanchuan commented 6 years ago

I'm going to leave it open to see if anyone upvote for this.

kgrajek commented 6 years ago

"Initial Scan" would be great feature!

octachrome commented 5 years ago

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:

fabiospampinato commented 3 years ago

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.

fabiospampinato commented 3 years ago

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