Change command output instead

This commit is contained in:
Douglas Eichelberger 2024-11-07 11:16:47 -08:00
parent acb4eddaca
commit ebe1e504da
2 changed files with 4 additions and 5 deletions

View File

@ -65,7 +65,9 @@ module Homebrew
formulae: json_info(formulae),
casks: json_info(casks),
}
puts JSON.pretty_generate(json)
# json v2.8.1 is inconsistent it how it renders empty arrays,
# so we use `[]` for consistency:
puts JSON.pretty_generate(json).gsub(/\[\n\n\s*\]/, "[]")
outdated = formulae + casks
else

View File

@ -20,12 +20,9 @@ RSpec.describe Homebrew::Cmd::Outdated do
}],
casks: [],
})
# json v2.8.1 is inconsistent it how it renders empty arrays,
# for now we allow multiple outputs:
alternate_json = expected_json.gsub("[]", "[\n\n]")
expect { brew "outdated", "--json=v2" }
.to output(match(/\A(#{Regexp.escape(expected_json)}|#{Regexp.escape(alternate_json)})\n\z/)).to_stdout
.to output("#{expected_json}\n").to_stdout
.and be_a_success
end
end