Giter Club home page Giter Club logo

Comments (10)

amasad avatar amasad commented on August 23, 2024

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.

neojski avatar neojski commented on August 23, 2024

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.

neojski avatar neojski commented on August 23, 2024

I'm not sure why this got closed. fs.watch is still better than fs.watchFile (although, as it looks, less reliable).

from watch.

OscarGodson avatar OscarGodson commented on August 23, 2024

Yeah, this mikeal/watch library is nice but its really slow sometimes. Takes up to like 3 seconds to notice changes.

from watch.

mikeal avatar mikeal commented on August 23, 2024

@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.

OscarGodson avatar OscarGodson commented on August 23, 2024

@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.

mikeal avatar mikeal commented on August 23, 2024

very strange. well, PR welcome then I guess :)

from watch.

paton avatar paton commented on August 23, 2024

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.

OscarGodson avatar OscarGodson commented on August 23, 2024

@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.

paton avatar paton commented on August 23, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.