remove cask's depencies from brew/leaves

This commit is contained in:
hyuraku 2023-06-20 22:37:39 +09:00
parent 9e747d8769
commit 3df4fa6803

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 and 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?