-
Notifications
You must be signed in to change notification settings - Fork 682
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
package resource: Fix brew
package detection
#2730
Conversation
This allows for package detection via `brew` to handle cases where a particular package formula exists but is not installed. Signed-off-by: Jerry Aldrich <[email protected]>
68e4b3a
to
8b5be69
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great improvement, but we can be more idiomatically correct Ruby-wise.
lib/resources/package.rb
Outdated
} | ||
# If package exists but is not installed, then `brew` output will not | ||
# contain `pkg['installed'][0]['version'] | ||
unless pkg.dig('installed', 0, 'version') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unless
...else
is really frowned-upon in Rubyland.
Let's just make this:
return {} unless pkg.dig('installed', 0, 'version')
# the package is installed, so we build up our pkg info hash
{
name: ...
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like that much more. Implemented in latest commit.
Thanks
Signed-off-by: Jerry Aldrich <[email protected]>
464a007
to
12cf780
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @jerryaldrichiii !
This allows for package detection via
brew
to handle cases where aparticular package formula exists but is not installed.