Comments (10)
Checkout my library sane which does exactly what you're talking about. Uses fs.watch and can be put into polling mode to use this library.
from watch.
I just tested a little bit and I want to watch 177958 files on mac which looks to be problematic. It looks like your library does not work around that.
from watch.
I'm not sure why this got closed. fs.watch is still better than fs.watchFile (although, as it looks, less reliable).
from watch.
Yeah, this mikeal/watch library is nice but its really slow sometimes. Takes up to like 3 seconds to notice changes.
from watch.
@OscarGodson in my experience that's mostly on Mac and is actually at the kernel/filesystem layer and can't be fixed in Node.
from watch.
@mikeal thats what Ive been told, but watchify is next to instant to notice changes and so is Grunt's watch task (I'm not using Grunt but tried it to check how fast it was). Also, I tried @amasad's sane library and thats also instant as well.
from watch.
very strange. well, PR welcome then I guess :)
from watch.
The reason I like this library a lot is that it doesn't use fs.watch.
fs.watch isn't compatible across OS's (because it relies on native OS APIs).
Example: When you save files in vim on OSX, the original file is replaced by a swap file. fs.watchFile detects this as a file change, while fs.watch detects this as a file being deleted and a new file being created.
That said, fs.watch is definitely a lot faster.
I definitely don't think we should remove fs.watchFile support entirely, but perhaps add support for both.
from watch.
@paton through a lib you can not trigger changes on swp files. You'd normally do something like check if the file ends in .js or something before triggering the callback. sane
does it like this
var watcher = sane('path/to/dir', ['**/*.js', '**/*.css']);
from watch.
@OscarGodson That doesn't fix the problem. To clarify: when saving example.js, fs.watch thinks that I entirely deleted the file, and then created a brand new file, which isn't the case. This happens even when filtering out swp files.
This can be problematic when you have callbacks you want to trigger only when a new file is really created (and not simply overwritten by a swp file)
from watch.
Related Issues (20)
- Error: ENOTDIR: not a directory, scandir HOT 5
- Action required: Greenkeeper could not be activated 🚨
- Action required: Greenkeeper could not be activated 🚨
- How to watch multiple directories? HOT 1
- Command is not shut down when file changes if long running process HOT 2
- Stop process from crashing if folder doesn't exist
- CLI: allow scrolling
- CLI - Get the change as parameter of the command HOT 1
- Upgrade merge to version 1.2.1 or later. HOT 6
- Watching Multiple Paths HOT 2
- Renaming a file for the first time does not trigger a delete event.
- Is this project still maintained? HOT 7
- Upgrade minimist to v.1.2.5
- mkdir -p issue
- [Electron] Old command is not halted when `watch` is re-triggered
- Upgrade minimist to v.1.2.6
- how to support hard disk space
- Not Found @cnakazawa/watch HOT 4
- Previous process not being killed
- Watch slow
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 watch.