summaryrefslogtreecommitdiff
path: root/lib/chef/provider/package/homebrew.rb
diff options
context:
space:
mode:
authorTim Smith <tsmith84@gmail.com>2020-04-17 16:32:46 -0700
committerTim Smith <tsmith84@gmail.com>2020-04-17 16:43:28 -0700
commit0cf9f8817e5b493cf93949b69a580dd45b39e021 (patch)
tree9dc9df6e3b2ef017b70153fc8031de5c8bfc3d7d /lib/chef/provider/package/homebrew.rb
parentd380678cb616e55682a3ca5a61a0be340f301ca0 (diff)
downloadchef-0cf9f8817e5b493cf93949b69a580dd45b39e021.tar.gz
Return empty hash from brew_info and avoid a bunch of nil checksmulti_package
Signed-off-by: Tim Smith <tsmith@chef.io>
Diffstat (limited to 'lib/chef/provider/package/homebrew.rb')
-rw-r--r--lib/chef/provider/package/homebrew.rb11
1 files changed, 3 insertions, 8 deletions
diff --git a/lib/chef/provider/package/homebrew.rb b/lib/chef/provider/package/homebrew.rb
index e3a0e471cc..d0321b2175 100644
--- a/lib/chef/provider/package/homebrew.rb
+++ b/lib/chef/provider/package/homebrew.rb
@@ -96,7 +96,7 @@ class Chef
# convert the array of hashes into a hash where the key is the package name
cmd_output = brew_cmd_output(command_array, allow_failure: true)
- return nil if cmd_output.empty? # empty std_out == bad package queried
+ return {} if cmd_output.empty? # empty std_out == bad package queried
Hash[Chef::JSONCompat.from_json(cmd_output).collect { |pkg| [pkg["name"], pkg] }]
end
@@ -110,8 +110,6 @@ class Chef
# @return [Hash] Package information
#
def package_info(package_name)
- return nil if brew_info.nil? # continue to raise the nil up the chain
-
# return the package hash if it's in the brew info hash
return brew_info[package_name] if brew_info[package_name]
@@ -135,9 +133,6 @@ class Chef
def installed_version(i)
p_data = package_info(i)
- # nil means we couldn't find anything
- return nil if p_data.nil?
-
if p_data["keg_only"]
if p_data["installed"].empty?
nil
@@ -165,8 +160,8 @@ class Chef
def available_version(i)
p_data = package_info(i)
- # nil means we couldn't find anything
- return nil if p_data.nil?
+ # nothing is available
+ return nil if p_data.empty?
p_data["versions"]["stable"]
end