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

Fix #771, Guard now fails with the 1 exit code when plugin is not available #791

Merged
merged 2 commits into from
Oct 8, 2015

Conversation

rymai
Copy link
Member

@rymai rymai commented Sep 23, 2015

i.e. running 'bundle exec guard init rspec' with guard-rspec not
available will exit with the 1 exit code.

@e2 Is it an acceptable solution?

Fixes #771, i.e. running 'bundle exec guard init rspec' with guard-rspec not
available will exit with the 1 exit code.
@rymai rymai added the 🐛 Bug Fix Fixes a bug label Sep 23, 2015
@rymai rymai assigned e2 Sep 23, 2015
@e2
Copy link
Contributor

e2 commented Sep 24, 2015

That's exactly how it should work.

The only thing I'd change is to use a custom exception instead of Errno::ENOENT, like Guardfile::Generator::NoSuchPlugin which takes the plugin name as an argument. This custom exception would be derived from Guardfile::Generator::Error, so catchingGuardfile::Generator::Error would handle future errors.

Kind of like here: https://github.com/guard/guard/blob/771-non-zero-exit-code-when-plugin-unavailable/lib/guard/cli/environments/valid.rb#L35

Ideally, the _ui calls would be moved too, so the generator just throws the exception with the plugin name, the exception itself generates the message (including a newline), and the handler would make the _ui call with the message. A spec would be written for the custom exception (formatting the message), just for coverage and so a typo doesn't blow up things when the exception does happen.

Anyway, I'm fine with just replacing Errno::ENOENT with a custom exception class.

@rymai
Copy link
Member Author

rymai commented Oct 7, 2015

Thanks for the feedback @e2 and sorry for not replying earlier! I will update the PR asap! ;)

@e2
Copy link
Contributor

e2 commented Oct 7, 2015

@rymai - don't worry about it :) I'm the one who hasn't done much in Guard for a long time.

(Though I mostly wanted to make sure Listen 3.x works for people without issues first - especially in Spring, so I avoided changing "too much")


def initialize(plugin_name)
@plugin_name = plugin_name
@class_name = plugin_name.gsub("-", "").capitalize

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary spacing detected.

@rymai rymai force-pushed the 771-non-zero-exit-code-when-plugin-unavailable branch from a527ec0 to d686a18 Compare October 8, 2015 17:35
@rymai
Copy link
Member Author

rymai commented Oct 8, 2015

Here you go @e2!

It feels good to work on Guard again, I hope I'll have more time to contribute from now on.

e2 added a commit that referenced this pull request Oct 8, 2015
…-unavailable

Fix #771, Guard now fails with the 1 exit code when plugin is not available
@e2 e2 merged commit 803facf into master Oct 8, 2015
@e2 e2 deleted the 771-non-zero-exit-code-when-plugin-unavailable branch October 8, 2015 21:30
@e2
Copy link
Contributor

e2 commented Oct 8, 2015

Awesome! Makes me want to get back to contributing a bit more too ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug Fix Fixes a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants