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

Handling of multiple watchdirs is undefined #634

Closed
e2 opened this issue Oct 8, 2014 · 3 comments
Closed

Handling of multiple watchdirs is undefined #634

e2 opened this issue Oct 8, 2014 · 3 comments
Labels

Comments

@e2
Copy link
Contributor

e2 commented Oct 8, 2014

TL;DR - avoid using multiple watched directories for now (-w option). If possible, watch the entire project and use "smarter" rules or custom plugins.

Example:

Given a tree:

/project/Guardfile
/project/spec/models/foo_spec.rb
/project/moduleA/spec/models/foo_spec.rb

watching /project and /project/modules, e.g.

guard -w . moduleA

results in ambiguous or non-existent relative paths passed to plugins, e.g.

touch /project/moduleA/spec/models/foo_spec.rb

triggers the event:

:modified, spec/models/foo_spec.rb  # because the /project/moduleA was substituted

Problem

Working with relative paths is more convenient (matching regexps in Guardfile), although the concept of multiple watch dirs breaks this.

Workaround

Reorganizing projects and directories to avoid needing multiple watched dirs with custom rules/configurations (consider multiple Guardfiles rather than multiple watch dirs).

Proper solution

Probably a directory keyword (similar to the idea of the existing group keyword) could allow having different plugin configurations for different directories.

Alternative solution

All paths and regexps should be either assumed relative to the given working directory, or absolute (if outside the project).

@e2 e2 added the bug label Oct 8, 2014
@e2
Copy link
Contributor Author

e2 commented Oct 8, 2014

"Extreme" example (related to above example):

~$ cd /project
/project$ bundle exec guard -G config/backend/Guardfile -w /project/moduleA/spec
/project$ touch /project/moduleA/spec/models/foo_spec.rb

Guard should call plugin's run_on_modification with moduleA/spec/models/foo_spec.rb , which is relative to current directory (so plugins can work on relative paths).

@e2
Copy link
Contributor Author

e2 commented Oct 22, 2014

fixed on master

@e2
Copy link
Contributor Author

e2 commented Oct 27, 2014

Fix released

@e2 e2 closed this as completed Oct 27, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant