Skip to content

Commit

Permalink
Change command output instead
Browse files Browse the repository at this point in the history
  • Loading branch information
dduugg committed Nov 7, 2024
1 parent acb4edd commit b3f7c9f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 3 additions & 1 deletion Library/Homebrew/cmd/outdated.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ def run
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]", "[]")

outdated = formulae + casks
else
Expand Down
5 changes: 1 addition & 4 deletions Library/Homebrew/test/cmd/outdated_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,9 @@
}],
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

0 comments on commit b3f7c9f

Please sign in to comment.