uses: allow checking deleted formulae.

This is useful for seeing when formulae are deleted if they are going to
leave behind any formulae that depend on them.

As a result, if there are any formulae returned return a non-zero/failed
exit status.
This commit is contained in:
Mike McQuaid 2017-04-17 15:06:24 +01:00
parent d950573f79
commit 5a2c91dbc2

View File

@ -28,7 +28,16 @@ module Homebrew
def uses
raise FormulaUnspecifiedError if ARGV.named.empty?
used_formulae = ARGV.formulae
used_formulae_missing = false
used_formulae = begin
ARGV.formulae
rescue FormulaUnavailableError => e
opoo e
used_formulae_missing = true
# If the formula doesn't exist: fake the needed formula object name.
ARGV.named.map { |name| OpenStruct.new name: name, full_name: name }
end
formulae = ARGV.include?("--installed") ? Formula.installed : Formula
recursive = ARGV.flag? "--recursive"
includes = []
@ -115,5 +124,6 @@ module Homebrew
return if uses.empty?
puts Formatter.columns(uses.map(&:full_name))
odie "Missing formulae should not have dependents!" if used_formulae_missing
end
end