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

Is there some way to watch directories? #758

Closed
winkler1 opened this issue Apr 7, 2015 · 4 comments
Closed

Is there some way to watch directories? #758

winkler1 opened this issue Apr 7, 2015 · 4 comments

Comments

@winkler1
Copy link

winkler1 commented Apr 7, 2015

Setup some code that uses dir name to take action... not the files within them.

Is there some way to trigger on dir changes? Can't seem to make it work, even with--

guard :shell do
  watch /./ do |m|
    m[0] + " has changed."
  end
end

Thanks!

@e2
Copy link
Contributor

e2 commented Apr 7, 2015

Actually, internally the Listen library does watch directories (except on BSD) - but changes to directories result in scanning them (for fields).

Directories aren't too useful to treat as "content" - you're better of using actual files one way or another.

In truth, since Listen tries to be as portable as possible, it barely even watches files properly (lots of workarounds to make that happen).

If you're curious, check out https://github.com/guard/listen - there's even a LISTEN_GEM_DEBUGGING=2 environment variable that shows the actual events happening and how they are handled.

What's your use case? Maybe there's some compromise possible. And what OS is this for?

@winkler1
Copy link
Author

winkler1 commented Apr 7, 2015

Hi-
The usecase is unusual, I'm using directory names to specify a series of DB objects to be created. The foldername is something like "Ad,Image,Video"... the code sees the dir name, parses it, and makes an ad with an image and video. Directories work well because resulting output is written to it.

This is on OSX.

Have used Listen.to to watch for file changes, it's fantastic :)

@e2
Copy link
Contributor

e2 commented Apr 7, 2015

I try to instead at least have a file that lists the directories.

You could try using the rb-fsevent gem directly.

@e2
Copy link
Contributor

e2 commented Jun 9, 2015

I added a feature request here: guard/listen#313

If this is still relevant for you, you can watch that issue there - I don't think there will be changes in Guard for this, since Guard doesn't distinguish between directories and files.

@e2 e2 closed this as completed Jun 9, 2015
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

2 participants