diff options
author | Tim Smith <tsmith84@gmail.com> | 2021-01-04 13:30:26 -0800 |
---|---|---|
committer | Tim Smith <tsmith84@gmail.com> | 2021-01-04 17:15:47 -0800 |
commit | 8fdfc62cc7a47c2d33db50d0a74d61fb431e1574 (patch) | |
tree | 995dc5065817f9babdef473518442bb7b0c593bf | |
parent | 2398e9cab41feaec9556ee9d160642f5d90acf05 (diff) | |
download | chef-8fdfc62cc7a47c2d33db50d0a74d61fb431e1574.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.rb | 2 | ||||
-rw-r--r-- | lib/chef/resource/homebrew_cask.rb | 6 |
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 876fac6bde..cb123d1225 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 "vim" 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) |