From 56a8f8f99d73ea2b40b460e48105008b3c4ffdef Mon Sep 17 00:00:00 2001 From: nandahkrishna <nanda.harishankar@gmail.com> Date: Fri, 18 Sep 2020 02:39:52 +0530 Subject: [PATCH] livecheck: fix TTY output for progress bar --- Library/Homebrew/livecheck/livecheck.rb | 9 +++++++-- Library/Homebrew/utils/tty.rb | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/livecheck/livecheck.rb b/Library/Homebrew/livecheck/livecheck.rb index df34a28410..0398964afb 100644 --- a/Library/Homebrew/livecheck/livecheck.rb +++ b/Library/Homebrew/livecheck/livecheck.rb @@ -75,7 +75,10 @@ module Homebrew formulae_to_check.length end - $stderr.puts Formatter.headline("Running checks", color: :blue) + Tty.with($stderr) do |stderr| + stderr.puts Formatter.headline("Running checks", color: :blue) + end + progress = ProgressBar.create( total: total_formulae, progress_mark: "#", @@ -182,7 +185,9 @@ module Homebrew if progress progress.finish - $stderr.print "#{Tty.up}#{Tty.erase_line}" * 2 + Tty.with($stderr) do |stderr| + stderr.print "#{Tty.up}#{Tty.erase_line}" * 2 + end end puts JSON.generate(formulae_checked.compact) diff --git a/Library/Homebrew/utils/tty.rb b/Library/Homebrew/utils/tty.rb index 3831344c86..774d1933be 100644 --- a/Library/Homebrew/utils/tty.rb +++ b/Library/Homebrew/utils/tty.rb @@ -88,7 +88,7 @@ module Tty SPECIAL_CODES.each do |name, code| define_singleton_method(name) do - if $stdout.tty? + if @stream.tty? "\033[#{code}" else "" -- GitLab