aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
Diffstat (limited to 'Library')
-rwxr-xr-xLibrary/Contributions/cmd/brew-leaves.rb17
1 files changed, 13 insertions, 4 deletions
diff --git a/Library/Contributions/cmd/brew-leaves.rb b/Library/Contributions/cmd/brew-leaves.rb
index f94809c9d..3da55c019 100755
--- a/Library/Contributions/cmd/brew-leaves.rb
+++ b/Library/Contributions/cmd/brew-leaves.rb
@@ -4,10 +4,10 @@
require 'formula'
-def get_used_by
+def get_used_by(formulae)
used_by = {}
- Formula.each do |f|
- next if f.deps == nil
+ formulae.each do |f|
+ next if f.nil? or f.deps.nil?
f.deps.each do |dep|
_deps = used_by[dep.to_s] || []
@@ -19,8 +19,17 @@ def get_used_by
return used_by
end
-deps_graph = get_used_by()
installed = HOMEBREW_CELLAR.children.select { |pn| pn.directory? }.collect { |pn| pn.basename.to_s }
+installed_formulae = installed.collect do |pn|
+ begin
+ Formula.factory(pn)
+ rescue FormulaUnavailableError
+ # Don't complain about directories from DIY installs
+ end
+end
+
+deps_graph = get_used_by(installed_formulae)
+
installed.each do |name|
deps = deps_graph[name] || []
puts name unless deps.any? { |dep| installed.include? dep.to_s }