Prevent warning and errors from breaking the sync

This commit is contained in:
Tommaso Negri
2024-12-03 14:39:24 +01:00
parent d8521a0fc7
commit e9f09adde2
+20 -3
View File
@@ -2,13 +2,14 @@
require "formula" require "formula"
require "json" require "json"
require "readall"
module Homebrew module Homebrew
module Cmd module Cmd
class BrewerTapContentInfo < AbstractCommand class BrewerTapContentInfo < AbstractCommand
cmd_args do cmd_args do
description <<~EOS description <<~EOS
Do something. Place a description here. Display the information about third-party casks and formulas.
EOS EOS
flag "--json", flag "--json",
description: "Print a JSON representation. Currently the default value for <version> is `v1` for " \ description: "Print a JSON representation. Currently the default value for <version> is `v1` for " \
@@ -19,16 +20,19 @@ module Homebrew
switch "--cask", "--casks", switch "--cask", "--casks",
description: "Treat all named arguments as casks." description: "Treat all named arguments as casks."
conflicts "--formula", "--cask" conflicts "--formula", "--cask"
named_args [:tap]
end end
def run def run
begin
original_stderr = $stderr.clone
$stderr.reopen(File.new("/dev/null", "w"))
formulae = [] formulae = []
casks = [] casks = []
Tap.each do |tap| Tap.each do |tap|
next if ["homebrew/core", "homebrew/cask"].include?(tap.name) next if ["homebrew/core", "homebrew/cask"].include?(tap.name)
next unless valid_tap? tap
unless args.cask? unless args.cask?
tap.formula_files.each do |formula_file| tap.formula_files.each do |formula_file|
@@ -49,6 +53,19 @@ module Homebrew
} }
puts JSON.pretty_generate(json) puts JSON.pretty_generate(json)
ensure
$stderr.reopen(original_stderr)
end
end
private
def valid_tap?(tap)
begin
Readall.valid_tap?(tap, aliases: true)
rescue Interrupt, RuntimeError
false
end
end end
end end
end end