aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cmd
diff options
context:
space:
mode:
authorMike McQuaid2015-03-07 11:55:14 +0000
committerMike McQuaid2015-03-08 11:13:33 +0000
commitd5f55334f15a4202aaff19f52bb588e9511f3951 (patch)
tree9d11bac717fa9d9a43a153e373c80d539bf72cb5 /Library/Homebrew/cmd
parent3b153820296d6e087c070440e732d661d31c283d (diff)
downloadbrew-d5f55334f15a4202aaff19f52bb588e9511f3951.tar.bz2
cmd/readall: add --syntax to check for valid Ruby.
Diffstat (limited to 'Library/Homebrew/cmd')
-rw-r--r--Library/Homebrew/cmd/readall.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/Library/Homebrew/cmd/readall.rb b/Library/Homebrew/cmd/readall.rb
index f43b30bfd..7bb921b88 100644
--- a/Library/Homebrew/cmd/readall.rb
+++ b/Library/Homebrew/cmd/readall.rb
@@ -5,9 +5,31 @@
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, IOError # ignore empty queue error
+ end
+ end
+ end
+ workers.map(&:join)
+ Homebrew.failed = failed
+ end
+
formulae = []
if ARGV.empty?
formulae = Formula.names