formulary: improve style

Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
This commit is contained in:
Carlo Cabrera 2025-07-10 20:25:17 +08:00 committed by Carlo Cabrera
parent 6141c6a181
commit 69ce5edd14
No known key found for this signature in database
GPG Key ID: C74D447FC549A1D0

View File

@ -139,11 +139,12 @@ module Formulary
raise new_exception, "", e.backtrace raise new_exception, "", e.backtrace
end end
ensure ensure
printed_to_stdout = $stdout.string.strip # TODO: Make printing to stdout an error so that we can print a tap name.
if printed_to_stdout.present? # See discussion at https://github.com/Homebrew/brew/pull/20226#discussion_r2195886888
if (printed_to_stdout = $stdout.string.strip.presence)
opoo <<~WARNING opoo <<~WARNING
Formula #{name} attempted to print the following while being loaded: Formula #{name} attempted to print the following while being loaded:
#{$stdout.string.strip} #{printed_to_stdout}
WARNING WARNING
end end
$stdout = old_stdout $stdout = old_stdout