aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew
diff options
context:
space:
mode:
authorMike McQuaid2015-03-07 11:55:14 +0000
committerMike McQuaid2015-03-08 11:13:33 +0000
commit290da5865f5f030fbe391b03d4345ca7c26106b4 (patch)
tree7ca5157dccc3e7ba0fe9cb8c4e21cae5154576ce /Library/Homebrew
parent5878311e0435d3c8ee2aecadb9e07882d2925829 (diff)
downloadhomebrew-290da5865f5f030fbe391b03d4345ca7c26106b4.tar.bz2
cmd/readall: add --syntax to check for valid Ruby.
Diffstat (limited to 'Library/Homebrew')
-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