extend/kernel: tighten type sig for ensure_formula_installed!
This does the same as #20356 for `ensure_formula_installed!`. See discussion at #20352. Unfortunately, one must still `require "formula"` before using this method because of the `returns(Formula)`, but tightening the type signature is generally a good idea anyway. Closes #20352.
This commit is contained in:
parent
29512728e3
commit
cf6c5acce0
@ -354,7 +354,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
return if gnu_tar_formula.blank?
|
return if gnu_tar_formula.blank?
|
||||||
|
|
||||||
ensure_formula_installed!(gnu_tar_formula, reason: "bottling")
|
ensure_formula_installed!(gnu_tar_formula.name, reason: "bottling")
|
||||||
|
|
||||||
gnu_tar_formula
|
gnu_tar_formula
|
||||||
end
|
end
|
||||||
|
|||||||
@ -442,10 +442,10 @@ module Kernel
|
|||||||
# Ensure the given formula is installed
|
# Ensure the given formula is installed
|
||||||
# This is useful for installing a utility formula (e.g. `shellcheck` for `brew style`)
|
# This is useful for installing a utility formula (e.g. `shellcheck` for `brew style`)
|
||||||
sig {
|
sig {
|
||||||
params(formula_or_name: T.any(String, Formula), reason: String, latest: T::Boolean, output_to_stderr: T::Boolean,
|
params(formula_name: String, reason: String, latest: T::Boolean, output_to_stderr: T::Boolean,
|
||||||
quiet: T::Boolean).returns(Formula)
|
quiet: T::Boolean).returns(Formula)
|
||||||
}
|
}
|
||||||
def ensure_formula_installed!(formula_or_name, reason: "", latest: false,
|
def ensure_formula_installed!(formula_name, reason: "", latest: false,
|
||||||
output_to_stderr: true, quiet: false)
|
output_to_stderr: true, quiet: false)
|
||||||
if output_to_stderr || quiet
|
if output_to_stderr || quiet
|
||||||
file = if quiet
|
file = if quiet
|
||||||
@ -455,19 +455,14 @@ module Kernel
|
|||||||
end
|
end
|
||||||
# Call this method itself with redirected stdout
|
# Call this method itself with redirected stdout
|
||||||
redirect_stdout(file) do
|
redirect_stdout(file) do
|
||||||
return ensure_formula_installed!(formula_or_name, latest:,
|
return ensure_formula_installed!(formula_name, latest:,
|
||||||
reason:, output_to_stderr: false)
|
reason:, output_to_stderr: false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
require "formula"
|
require "formula"
|
||||||
|
|
||||||
formula = if formula_or_name.is_a?(Formula)
|
formula = Formula[formula_name]
|
||||||
formula_or_name
|
|
||||||
else
|
|
||||||
Formula[formula_or_name]
|
|
||||||
end
|
|
||||||
|
|
||||||
reason = " for #{reason}" if reason.present?
|
reason = " for #{reason}" if reason.present?
|
||||||
|
|
||||||
unless formula.any_version_installed?
|
unless formula.any_version_installed?
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user