Skip to content
Snippets Groups Projects
Commit 8667387b authored by Misty De Meo's avatar Misty De Meo
Browse files

Revert "Removew brew-which"

This reverts commit c0a32c81eb1b176448cd41866f2d22427c729522.

Will add a deprecation notice and remove at a later point in time.
parent 9ccf9655
No related branches found
No related tags found
No related merge requests found
require 'extend/pathname'
module Homebrew
def which_versions which_brews=nil
brew_links = Array.new
version_map = Hash.new
real_cellar = HOMEBREW_CELLAR.realpath
(HOMEBREW_PREFIX/'opt').subdirs.each do |path|
next unless path.symlink? && path.resolved_path_exists?
brew_links << Pathname.new(path.realpath)
end
brew_links = brew_links.collect{|p|p.relative_path_from(real_cellar).to_s}.reject{|p|p.start_with?("../")}
brew_links.each do |p|
parts = p.split("/")
next if parts.count < 2 # Shouldn't happen for normally installed brews
brew = parts.shift
version = parts.shift
next unless which_brews.include? brew if which_brews
versions = version_map[brew] || []
versions << version unless versions.include? version
version_map[brew] = versions
end
return version_map
end
def which
which_brews = ARGV.named.empty? ? nil : ARGV.named
brews = which_versions which_brews
brews.keys.sort.each do |b|
puts "#{b}: #{brews[b].sort*' '}"
end
puts
end
end
Homebrew.which
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment