brew/Library/Homebrew/cmd/readall.rb

48 lines
1.3 KiB
Ruby
Raw Normal View History

2020-10-10 14:16:11 +02:00
# typed: false
# frozen_string_literal: true
require "readall"
2019-04-17 18:25:08 +09:00
require "cli/parser"
module Homebrew
2016-09-26 01:44:51 +02:00
module_function
2018-11-05 18:23:26 +05:30
def readall_args
Homebrew::CLI::Parser.new do
usage_banner <<~EOS
`readall` [<options>] [<tap>]
2018-11-05 18:23:26 +05:30
2020-06-16 20:35:40 +02:00
Import all items from the specified <tap>, or from all installed taps if none is provided.
This can be useful for debugging issues across all items when making
2018-11-05 18:23:26 +05:30
significant changes to `formula.rb`, testing the performance of loading
2020-06-16 20:35:40 +02:00
all items or checking if any current formulae/casks have Ruby issues.
2018-11-05 18:23:26 +05:30
EOS
switch "--aliases",
description: "Verify any alias symlinks in each tap."
switch "--syntax",
description: "Syntax-check all of Homebrew's Ruby files (if no `<tap>` is passed)."
2018-11-05 18:23:26 +05:30
end
end
def readall
2020-07-30 18:40:10 +02:00
args = readall_args.parse
2018-11-05 18:23:26 +05:30
if args.syntax? && args.no_named?
scan_files = "#{HOMEBREW_LIBRARY_PATH}/**/*.rb"
2020-06-16 20:35:40 +02:00
ruby_files = Dir.glob(scan_files).reject { |file| file =~ %r{/(vendor)/} }
Homebrew.failed = true unless Readall.valid_ruby_syntax?(ruby_files)
end
2018-11-05 18:23:26 +05:30
options = { aliases: args.aliases? }
taps = if args.no_named?
Tap
else
args.named.map { |t| Tap.fetch(t) }
end
taps.each do |tap|
Homebrew.failed = true unless Readall.valid_tap?(tap, options)
end
2010-07-18 14:20:54 -07:00
end
end