-
-
Notifications
You must be signed in to change notification settings - Fork 578
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
Watching symlinks [feature] #31
Comments
any particular reason to make it opt-in and not default behavior? |
@paulmillr you are right, it should be default behavior |
I'm currently playing with Unitech/PM2 (which uses chokidar to trigger restarts on file changes). My use case is a symlink-based deployment strategy—where a symlink points to the current release directory. Since neither the symlinked directory nor any files in it ever change (only the symlink), and chokidar is following symlinks, pm2 will never be notified of a change. I found #56 and it seems like the more recent thinking is that the current behavior should be retained (no breaking changes). Given that, is the way forward to add a Thanks! cc @Unitech |
@matthewwithanm Yes, improved symlink functionality is desired before bumping to 1.0.0. PR welcome. Adding a |
@es128 +1 on this issue, would be amazing to be able to use symlinks with watchify |
Apparently this was not the case when this issue was written, but as of now (testing with node 0.10.33), What's left is to attain parity for |
Personally, I'd like to be able to watch the symlinks themselves; i.e. not transparently follow symlinks. |
In the use case you described above, if the transparent following is made to work correctly, you'd end up getting The current behavior in fsevents mode is more like watching the link itself, so there'd be a single Then, I'd like to be able to offer an option turn off the transparent following and emit on the symlinks themselves. But since the |
Turns out it wasn't that difficult after all: 284148b |
👍 Cool! |
Symlink support is looking pretty good in the master branch. Closing the issue. The symlink-specific tests fail on Windows, but I suspect nobody is going to care. |
dude you are awesome. thanks for your fast fixes! |
@scamden It would be awesome if you could give the master branch code a try under watchify and confirm whether it behaves the way you'd like. |
so like fork watchify and set the chokidar package json entry to hit your github repo? (sorry a bit of a noob to npm still) |
From your project dir, ought to be as simple as: cd node_modules/watchify
npm i paulmillr/chokidar |
wow that makes me feel dumb. but also grateful :) will check it out On 4 December 2014 at 15:50, Elan Shanker notifications@github.com wrote:
Sterling Camden |
yep it seems to work! the first time i tried it failed, but i have numerous versions of watchify installed throughout a fairly complex build so i prob installed to the wrong one. once i installed in a simple repo it worked for both internal symlinks and npm linked modules! thank you! |
@es128 spoke a little soon, the current impl doesn't work for npm links, the reason it was working for me was because i hadn't linked the module locally, so i was requiring the module from the global space where it was linked. |
it looks like if the watched parent directory is not an actual parent of the symlinked files they don't get changes, so linking to something up the directory tree, or to a sibling doesn't get changes. i'm not at all confident that i understand all that's going on there, but maybe should check the |
trying it that does fix the issue, but i imagine you want to create fewer watchers, while this creates one for every file not inside the package directory |
@scamden Good catch. I believe the underlying cause here is that I'm going to double-check my assumptions, but if I'm right then I'll be closing your PR as the better solution will be to replace every instance of The good news is this can be a patch release, so it won't require any further coordination with watchify to get it corrected there. |
nm that's not what |
wait... yes it does... ok I'm going to stop dumping my stream of consciousness into these comments... will let you know when I'm done fixing it |
Haha no worries I always feel like him doing that. Just so you know I found
|
So I was probably wrong about my initial thought that it was the double
|
I'm having a very hard time setting up a unit test for that that fails with I'll wait for further feedback from you if you can show how to reproduce any other problems. |
took at stab at setting up a test today, but can't get it to pass, will try On 12 December 2014 at 19:33, Elan Shanker notifications@github.com wrote:
Sterling Camden |
@es128 ok i finally wrote a test that fails before my patch and passes after. the test only fails when using fsevents. it seems the tests don't run with fsevents true on mac, so the only way i could make the test fail was to override options to watchify uses fsevents in it's version of chokdar because it passes i need your guidance on how to proceed. the test is only meaningful when run with useFsEvents, but that condition isn't tested by default on mac. should i just leave in the override? or do you even want this test? |
fsevents mode does get tested: https://github.com/paulmillr/chokidar/blob/master/test.js#L34-L36 What happens when you run the tests that makes you think it is not testing fsevents mode? |
You could just open the PR and we can collaborate on it from there |
oh i see what happened here. its a bug in mocha's it.only impl. I use On 17 December 2014 at 12:53, Elan Shanker notifications@github.com wrote:
Sterling Camden |
kk here ya go: |
Chokidar might watch symlinks, something like http://stackoverflow.com/questions/9364514/how-to-watch-symlinked-files-in-node-js-using-watchfile
The ideal would be probably watching both the symlink and the real file (and update real file watcher, if the symlink changes).
I guess it might be as opt-in under a config option...
The text was updated successfully, but these errors were encountered: