From 81a7d6edd732d903ab653400ee4a51d4d8fb896a Mon Sep 17 00:00:00 2001 From: Mohammad Zain Abbas Date: Sun, 7 Aug 2022 17:13:17 +0200 Subject: [PATCH] Fixed issue with --json flag for resources --- Library/Homebrew/livecheck/livecheck.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Library/Homebrew/livecheck/livecheck.rb b/Library/Homebrew/livecheck/livecheck.rb index 1d381c2710..e988ba6535 100644 --- a/Library/Homebrew/livecheck/livecheck.rb +++ b/Library/Homebrew/livecheck/livecheck.rb @@ -285,7 +285,7 @@ module Homebrew # Check current and latest resources (if "--resources" flag is given) # Only check current and latest versions if we have resources to check against - if check_resources && formula_or_cask.resources.present? + if check_resources && formula_or_cask.is_a?(Formula) && formula_or_cask.resources.present? current_resources = formula_or_cask.resources.map do |resource| { name: resource.name, version: resource.version, livecheckable: resource.livecheckable? } end @@ -348,7 +348,7 @@ module Homebrew info[:meta][:head_only] = true if formula&.head_only? info[:meta].merge!(version_info[:meta]) if version_info.present? && version_info.key?(:meta) - if check_resources && formula_or_cask.resources.present? + if check_resources && formula_or_cask.is_a?(Formula) && formula_or_cask.resources.present? resources_info = [] latest_resources_names = latest_resources.map { |r| r[:name] } current_resources.each do |resource| @@ -365,16 +365,16 @@ module Homebrew is_newer_than_upstream = current > latest is_outdated = (current != latest) && !is_newer_than_upstream - info = {} - info[:resource] = resource[:name] - info[:meta] = { livecheckable: resource[:livecheckable] } - info[:version] = { + res_info = {} + res_info[:resource] = resource[:name] + res_info[:meta] = { livecheckable: resource[:livecheckable] } + res_info[:version] = { current: current_str, latest: latest_str, newer_than_upstream: is_newer_than_upstream, outdated: is_outdated, } - resources_info << info + resources_info << res_info end info[:resources] = resources_info end