diff --git a/Library/Homebrew/bundle/cask_installer.rb b/Library/Homebrew/bundle/cask_installer.rb index 781bbf57bf..4014666d73 100644 --- a/Library/Homebrew/bundle/cask_installer.rb +++ b/Library/Homebrew/bundle/cask_installer.rb @@ -41,7 +41,7 @@ module Homebrew case v when TrueClass "--#{k}" - when FalseClass + when FalseClass, NilClass nil else "--#{k}=#{v}" diff --git a/Library/Homebrew/bundle/dsl.rb b/Library/Homebrew/bundle/dsl.rb index 5196c17499..3431cc01c3 100644 --- a/Library/Homebrew/bundle/dsl.rb +++ b/Library/Homebrew/bundle/dsl.rb @@ -42,7 +42,7 @@ module Homebrew def cask_args(args) raise "cask_args(#{args.inspect}) should be a Hash object" unless args.is_a? Hash - @cask_arguments = args + @cask_arguments.merge!(args) end def brew(name, options = {}) diff --git a/Library/Homebrew/test/bundle/dsl_spec.rb b/Library/Homebrew/test/bundle/dsl_spec.rb index 636bda3334..27f47bffd3 100644 --- a/Library/Homebrew/test/bundle/dsl_spec.rb +++ b/Library/Homebrew/test/bundle/dsl_spec.rb @@ -60,6 +60,20 @@ RSpec.describe Homebrew::Bundle::Dsl do end end + context "with multiple cask_args" do + subject(:dsl) do + dsl_from_string <<~EOS + cask_args appdir: '/global-apps' + cask_args require_sha: true + cask_args appdir: '~/my-apps' + EOS + end + + it "merges the arguments" do + expect(dsl.cask_arguments).to eql(appdir: "~/my-apps", require_sha: true) + end + end + context "with invalid input" do it "handles completely invalid code" do expect { dsl_from_string "abcdef" }.to raise_error(RuntimeError)