Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A few feature requests #58

Open
ghost opened this issue May 18, 2018 · 10 comments
Open

A few feature requests #58

ghost opened this issue May 18, 2018 · 10 comments

Comments

@ghost
Copy link

ghost commented May 18, 2018

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:

  • Initial Scan (report found files as when starting the watcher)
  • A "create" event (for when files are created)
  • When a directory is removed in a recursive watch, report it's contents recursively as individual 'remove' events as well

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
Copy link
Owner

yuanchuan commented May 19, 2018

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
Copy link
Author

ghost commented May 19, 2018

Maybe make them optional like the recursive option?

@ghost ghost closed this as completed May 19, 2018
@ghost ghost reopened this May 19, 2018
@ghost
Copy link
Author

ghost commented May 19, 2018

Oops that was unintentional

@yuanchuan
Copy link
Owner

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

@ghost
Copy link
Author

ghost commented May 19, 2018

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
Copy link
Owner

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

@kgrajek
Copy link

kgrajek commented Jul 11, 2018

"Initial Scan" would be great feature!

@octachrome
Copy link

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:

  • I implemented initial scan using readdirp, with a counter to ensure the scan stops early when the directory tree is too deep
  • I am thinking of implementing individual file events on rm -rf by maintaining a list of all files in the directory
  • I also need to workaround an issue on Linux where copying a deep directory structure into a watched directory does not fire events for new files, because the recursive watch is added too slowly. I will probably resolve this by using readdirp to find the directory contents whenever a new directory is created.

@fabiospampinato
Copy link

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
Copy link

fabiospampinato commented Nov 21, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants