brew/Library/Homebrew/cmd/readall.rb

53 lines
1.3 KiB
Ruby
Raw Normal View History

# `brew readall` tries to import all formulae one-by-one.
# This can be useful for debugging issues across all formulae
2010-07-18 14:20:54 -07:00
# when making significant changes to formula.rb,
# or to determine if any current formulae have Ruby issues
require 'formula'
require 'cmd/tap'
require 'thread'
module Homebrew
def readall
if ARGV.delete("--syntax")
ruby_files = Queue.new
Dir.glob("#{HOMEBREW_LIBRARY}/Homebrew/**/*.rb").each do |rb|
ruby_files << rb
end
failed = false
workers = (0...Hardware::CPU.cores).map do
Thread.new do
begin
while rb = ruby_files.pop(true)
nostdout { failed = true unless system "ruby", "-c", "-w", rb }
end
rescue ThreadError # ignore empty queue error
end
end
end
workers.map(&:join)
Homebrew.failed = failed
end
formulae = []
if ARGV.named.empty?
formulae = Formula.full_names
else
2015-06-08 18:05:58 +08:00
tap = Tap.new(*tap_args)
2015-06-13 14:32:10 +08:00
raise TapUnavailableError, tap.name unless tap.installed?
2015-06-08 18:05:58 +08:00
formulae = tap.formula_files
end
formulae.sort.each do |n|
begin
Formulary.factory(n)
rescue Exception => e
onoe "problem in #{Formulary.path(n)}"
puts e
Homebrew.failed = true
end
end
2010-07-18 14:20:54 -07:00
end
end