Comments (10)
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.
from node-watch.
Maybe make them optional like the recursive
option?
from node-watch.
Oops that was unintentional
from node-watch.
That may be huge work :D
Could you share your current workarounds?
from node-watch.
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.
from node-watch.
I'm going to leave it open to see if anyone upvote for this.
from node-watch.
"Initial Scan" would be great feature!
from node-watch.
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.
from node-watch.
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.
from node-watch.
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
from node-watch.
Related Issues (20)
- Follow symlink HOT 2
- watch dir bug HOT 2
- Calling close() before the watcher is ready does nothing HOT 2
- Avoid synchronous fs calls HOT 1
- Catch errors when adding watchers for child directories HOT 1
- Catch error when use Node 14.15.3 on Linux SysTem HOT 2
- I got this error at first use lib in nodejs using express HOT 2
- node-watch is not working recursive in Ubuntu under WSL HOT 5
- when watch a dir that mount by nfs, if not work HOT 2
- New ES syntax HOT 2
- Only pass skip on initial recurse
- Travis CI is no longer free, try to switch to GitHub CI
- Fix tests on Windows
- fs.watch() not detecting changes to file from git operation HOT 3
- images update problem HOT 3
- Can TEMP_DIR able to change ?
- Is there a way, or a best practice to scan this large amount of files for processing ? HOT 4
- Add ignore option HOT 7
- multiple events for a file sent over network HOT 2
- High CPU consumption on window service HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-watch.