Merge pull request #10054 from hyuraku/livecheck-raise-error

livecheck: raise error if no watchlist
This commit is contained in:
Sam Ford 2020-12-20 17:48:23 -05:00 committed by GitHub
commit 2ddb71af77
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 46 additions and 36 deletions

View File

@ -60,7 +60,8 @@ module Homebrew
puts ENV["HOMEBREW_LIVECHECK_WATCHLIST"] if ENV["HOMEBREW_LIVECHECK_WATCHLIST"].present?
end
formulae_and_casks_to_check = if args.tap
formulae_and_casks_to_check =
if args.tap
tap = Tap.fetch(args.tap)
formulae = args.cask? ? [] : tap.formula_files.map { |path| Formulary.factory(path) }
casks = args.formula? ? [] : tap.cask_files.map { |path| Cask::CaskLoader.load(path) }
@ -95,7 +96,9 @@ module Homebrew
rescue Errno::ENOENT => e
onoe e
end
end.sort_by do |formula_or_cask|
else
raise UsageError, "A watchlist file is required when no arguments are given."
end&.sort_by do |formula_or_cask|
formula_or_cask.respond_to?(:token) ? formula_or_cask.token : formula_or_cask.name
end

View File

@ -21,4 +21,11 @@ describe "brew livecheck", :integration_test do
.and not_to_output.to_stderr
.and be_a_success
end
it "gives an error when no arguments are given and there's no watchlist" do
expect { brew "livecheck" }
.to output(/Invalid usage: A watchlist file is required when no arguments are given\./).to_stderr
.and not_to_output.to_stdout
.and be_a_failure
end
end