utils: import {ohai,puts}_stdout_or_stderr

Fixes #10536
This commit is contained in:
Mike McQuaid 2021-02-05 15:03:31 +00:00
parent 984eb3f878
commit 72cb6ffd12
No known key found for this signature in database
GPG Key ID: 48A898132FD8EE70
2 changed files with 16 additions and 16 deletions

View File

@ -15,22 +15,6 @@ module Homebrew
module_function
def ohai_stdout_or_stderr(message)
if $stdout.tty?
ohai(message)
else
$stderr.puts(ohai_title(message))
end
end
def puts_stdout_or_stderr(message)
if $stdout.tty?
puts(message)
else
$stderr.puts(message)
end
end
def update_preinstall_header(args:)
@update_preinstall_header ||= begin
ohai_stdout_or_stderr "Auto-updated Homebrew!" if args.preinstall?

View File

@ -111,6 +111,22 @@ module Kernel
puts sput
end
def ohai_stdout_or_stderr(message)
if $stdout.tty?
ohai(message)
else
$stderr.puts(ohai_title(message))
end
end
def puts_stdout_or_stderr(message)
if $stdout.tty?
puts(message)
else
$stderr.puts(message)
end
end
def odebug(title, *sput, always_display: false)
debug = if respond_to?(:debug)
debug?