unpack_strategy/zip: avoid loading formulae unnecessarily

If we already have `unzip` in `PATH`, let's skip trying to load the
`unzip` formula.
This commit is contained in:
Carlo Cabrera 2023-05-31 00:06:55 +08:00
parent 8917acac95
commit 0867534f3e
No known key found for this signature in database
GPG Key ID: C74D447FC549A1D0

View File

@ -23,11 +23,13 @@ module UnpackStrategy
.returns(SystemCommand::Result) .returns(SystemCommand::Result)
} }
def extract_to_dir(unpack_dir, basename:, verbose:) def extract_to_dir(unpack_dir, basename:, verbose:)
unzip = begin unzip = if which("unzip").blank?
begin
Formula["unzip"] Formula["unzip"]
rescue FormulaUnavailableError rescue FormulaUnavailableError
nil nil
end end
end
with_env(TZ: "UTC") do with_env(TZ: "UTC") do
quiet_flags = verbose ? [] : ["-qq"] quiet_flags = verbose ? [] : ["-qq"]