summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith84@gmail.com>2021-01-04 13:30:26 -0800
committerTim Smith <tsmith84@gmail.com>2021-01-04 13:30:26 -0800
commit73f5d87f6d1a6c2e9ca519029a70a722520d6905 (patch)
tree6ab58e093593c979e8d0bd7532e374bc0b05a85c
parent95ea3116cc2642e00800ce68fdfc0cb96c7b3b3c (diff)
downloadchef-73f5d87f6d1a6c2e9ca519029a70a722520d6905.tar.gz
Fix homebrew_cask for the new syntax
Also add a CI test for installing a small cask Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--kitchen-tests/cookbooks/end_to_end/recipes/macos.rb2
-rw-r--r--lib/chef/resource/homebrew_cask.rb6
2 files changed, 5 insertions, 3 deletions
diff --git a/kitchen-tests/cookbooks/end_to_end/recipes/macos.rb b/kitchen-tests/cookbooks/end_to_end/recipes/macos.rb
index 5f2278538b..d6a3b40bf8 100644
--- a/kitchen-tests/cookbooks/end_to_end/recipes/macos.rb
+++ b/kitchen-tests/cookbooks/end_to_end/recipes/macos.rb
@@ -83,6 +83,8 @@ homebrew_package "nethack" do
action :purge
end
+homebrew_cask "do-not-disturb"
+
include_recipe "::_dmg_package"
include_recipe "::_macos_userdefaults"
include_recipe "::_ohai_hint"
diff --git a/lib/chef/resource/homebrew_cask.rb b/lib/chef/resource/homebrew_cask.rb
index 3b0974348c..4c68afaab0 100644
--- a/lib/chef/resource/homebrew_cask.rb
+++ b/lib/chef/resource/homebrew_cask.rb
@@ -60,7 +60,7 @@ class Chef
unless casked?
converge_by("install cask #{new_resource.cask_name} #{new_resource.options}") do
- shell_out!("#{new_resource.homebrew_path} cask install #{new_resource.cask_name} #{new_resource.options}",
+ shell_out!("#{new_resource.homebrew_path} install --cask #{new_resource.cask_name} #{new_resource.options}",
user: new_resource.owner,
env: { "HOME" => ::Dir.home(new_resource.owner), "USER" => new_resource.owner },
cwd: ::Dir.home(new_resource.owner))
@@ -75,7 +75,7 @@ class Chef
if casked?
converge_by("uninstall cask #{new_resource.cask_name}") do
- shell_out!("#{new_resource.homebrew_path} cask uninstall #{new_resource.cask_name}",
+ shell_out!("#{new_resource.homebrew_path} uninstall --cask #{new_resource.cask_name}",
user: new_resource.owner,
env: { "HOME" => ::Dir.home(new_resource.owner), "USER" => new_resource.owner },
cwd: ::Dir.home(new_resource.owner))
@@ -93,7 +93,7 @@ class Chef
# @return [Boolean]
def casked?
unscoped_name = new_resource.cask_name.split("/").last
- shell_out!("#{new_resource.homebrew_path} cask list 2>/dev/null",
+ shell_out!("#{new_resource.homebrew_path} list --cask 2>/dev/null",
user: new_resource.owner,
env: { "HOME" => ::Dir.home(new_resource.owner), "USER" => new_resource.owner },
cwd: ::Dir.home(new_resource.owner)).stdout.split.include?(unscoped_name)