aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cask/lib
diff options
context:
space:
mode:
authorKaito Udagawa2016-11-21 04:13:29 +0900
committerKaito Udagawa2016-11-21 04:13:29 +0900
commitdf635c8259dffca891424352765088a3b88a87d2 (patch)
treea07dcf3683057ed8256a94677b736765e86b722d /Library/Homebrew/cask/lib
parent0c22cc45e6fe7da64f037fc2fc1556c0e967d55f (diff)
downloadbrew-df635c8259dffca891424352765088a3b88a87d2.tar.bz2
cask: compact the code
Diffstat (limited to 'Library/Homebrew/cask/lib')
-rw-r--r--Library/Homebrew/cask/lib/hbc/artifact/pkg.rb23
1 files changed, 11 insertions, 12 deletions
diff --git a/Library/Homebrew/cask/lib/hbc/artifact/pkg.rb b/Library/Homebrew/cask/lib/hbc/artifact/pkg.rb
index fffb10cae..0569d2a86 100644
--- a/Library/Homebrew/cask/lib/hbc/artifact/pkg.rb
+++ b/Library/Homebrew/cask/lib/hbc/artifact/pkg.rb
@@ -54,24 +54,23 @@ module Hbc
]
args << "-verboseR" if Hbc.verbose
args << "-allowUntrusted" if pkg_install_opts :allow_untrusted
- with_choices_file pkg_install_opts(:choices) do |choices_path|
+ with_choices_file do |choices_path|
args << "-applyChoiceChangesXML" << choices_path if choices_path
@command.run!("/usr/sbin/installer", sudo: true, args: args, print_stdout: true)
end
end
- def with_choices_file(choices)
- unless choices
- yield nil
- return
- end
+ def with_choices_file
+ return yield nil unless pkg_install_opts(:choices)
- begin
- file = Tempfile.new(["choices", ".xml"])
- file.write Plist::Emit.dump(choices)
- yield file.path
- ensure
- file.close(true)
+ Tempfile.open(["choices", ".xml"]) do |file|
+ begin
+ file.write Plist::Emit.dump(pkg_install_opts(:choices))
+ file.close
+ yield file.path
+ ensure
+ file.unlink
+ end
end
end
end