From e1ce5c852dc68783ab4741173173824b1e79a266 Mon Sep 17 00:00:00 2001 From: Dawid Dziurla Date: Wed, 1 Apr 2020 12:01:55 +0200 Subject: [PATCH] github: return output if JSON parsing is not desired --- Library/Homebrew/utils/github.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Library/Homebrew/utils/github.rb b/Library/Homebrew/utils/github.rb index b885c065f8..e84a68d2f2 100644 --- a/Library/Homebrew/utils/github.rb +++ b/Library/Homebrew/utils/github.rb @@ -172,7 +172,7 @@ module GitHub end end - def open_api(url, data: nil, request_method: nil, scopes: [].freeze) + def open_api(url, data: nil, request_method: nil, scopes: [].freeze, parse_json: true) # This is a no-op if the user is opting out of using the GitHub API. return block_given? ? yield({}) : {} if ENV["HOMEBREW_NO_GITHUB_API"] @@ -227,11 +227,11 @@ module GitHub return if http_code == "204" # No Content - json = JSON.parse output + output = JSON.parse output if parse_json if block_given? - yield json + yield output else - json + output end rescue JSON::ParserError => e raise Error, "Failed to parse JSON response\n#{e.message}", e.backtrace