Merge pull request #15573 from hyuraku/remove-cask-depencies-from-brew-leaves

remove cask's depencies from brew/leaves
This commit is contained in:
Mike McQuaid 2023-06-20 16:21:08 +01:00 committed by GitHub
commit f0be2ca4d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -11,7 +11,7 @@ module Homebrew
def leaves_args
Homebrew::CLI::Parser.new do
description <<~EOS
List installed formulae that are not dependencies of another installed formula.
List installed formulae that are not dependencies of another installed formula or cask.
EOS
switch "-r", "--installed-on-request",
description: "Only list leaves that were manually installed."
@ -36,7 +36,10 @@ module Homebrew
args = leaves_args.parse
leaves_list = Formula.installed - Formula.installed.flat_map(&:runtime_formula_dependencies)
casks_runtime_dependencies = Cask::Caskroom.casks.flat_map do |cask|
CaskDependent.new(cask).runtime_dependencies.map(&:to_formula)
end
leaves_list -= casks_runtime_dependencies
leaves_list.select!(&method(:installed_on_request?)) if args.installed_on_request?
leaves_list.select!(&method(:installed_as_dependency?)) if args.installed_as_dependency?