Skip to content

Commit bfce68a

Browse files
authored
Merge pull request #19921 from Homebrew/cask_args-combine
bundle/dsl: combine cask_args calls
2 parents 0be3fbd + 288984b commit bfce68a

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

Library/Homebrew/bundle/cask_installer.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def self.install(name, preinstall: true, no_upgrade: false, verbose: false, forc
4141
case v
4242
when TrueClass
4343
"--#{k}"
44-
when FalseClass
44+
when FalseClass, NilClass
4545
nil
4646
else
4747
"--#{k}=#{v}"

Library/Homebrew/bundle/dsl.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def process
4242
def cask_args(args)
4343
raise "cask_args(#{args.inspect}) should be a Hash object" unless args.is_a? Hash
4444

45-
@cask_arguments = args
45+
@cask_arguments.merge!(args)
4646
end
4747

4848
def brew(name, options = {})

Library/Homebrew/test/bundle/dsl_spec.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,20 @@ def dsl_from_string(string)
6060
end
6161
end
6262

63+
context "with multiple cask_args" do
64+
subject(:dsl) do
65+
dsl_from_string <<~EOS
66+
cask_args appdir: '/global-apps'
67+
cask_args require_sha: true
68+
cask_args appdir: '~/my-apps'
69+
EOS
70+
end
71+
72+
it "merges the arguments" do
73+
expect(dsl.cask_arguments).to eql(appdir: "~/my-apps", require_sha: true)
74+
end
75+
end
76+
6377
context "with invalid input" do
6478
it "handles completely invalid code" do
6579
expect { dsl_from_string "abcdef" }.to raise_error(RuntimeError)

0 commit comments

Comments
 (0)