aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cmd/outdated.rb
blob: 40aa7a470bdd75b6915815cd36aec23c3b58c8a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
require 'formula'

module Homebrew extend self
  def outdated
    outdated_brews.each do |f|
      if $stdout.tty? and not ARGV.flag? '--quiet'
        versions = f.rack.cd{ Dir['*'] }.join(', ')
        puts "#{f.name} (#{versions} < #{f.version})"
      else
        puts f.name
      end
    end
  end

  def outdated_brews
    HOMEBREW_CELLAR.subdirs.map do |rack|
      # Skip kegs with no versions installed
      next unless rack.subdirs

      # Skip HEAD formulae, consider them "evergreen"
      next if rack.subdirs.map{ |keg| keg.basename.to_s }.include? "HEAD"

      name = rack.basename.to_s
      f = Formula.factory name rescue nil
      f if f and not f.installed?
    end.compact
  end
end