Skip to content

Commit

Permalink
Merge pull request #428 from Homebrew/system_command
Browse files Browse the repository at this point in the history
cmd/generate-analytics-api: avoid system_command
  • Loading branch information
Bo98 authored Jan 31, 2024
2 parents 4c734ed + 5c8a7f9 commit 8f3efc1
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions cmd/generate-analytics-api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,20 @@ def run_formula_analytics(*args)
puts "brew formula-analytics #{args.join(" ")}"

retries = 0
result = system_command HOMEBREW_BREW_FILE, args: ["formula-analytics", *args], print_stderr: false

while !result.success? && retries < MAX_RETRIES
$stderr.puts(result.stderr)
result = Utils.popen_read(HOMEBREW_BREW_FILE, "formula-analytics", *args)

while !$CHILD_STATUS.success? && retries < MAX_RETRIES
# Give InfluxDB some more breathing room.
sleep 4**(retries+2)

retries += 1
puts "Retrying #{args.join(" ")} (#{retries}/#{MAX_RETRIES})..."
result = system_command HOMEBREW_BREW_FILE, args: ["formula-analytics", *args], print_stderr: false
result = Utils.popen_read(HOMEBREW_BREW_FILE, "formula-analytics", *args)
end

odie "`brew formula-analytics #{args.join(" ")}` failed: #{result.merged_output}" unless result.success?
odie "`brew formula-analytics #{args.join(" ")}` failed: #{result.merged_output}" unless $CHILD_STATUS.success?

result.stdout
result
end

def generate_analytics_api
Expand Down

0 comments on commit 8f3efc1

Please sign in to comment.