lib/cli/ui/stdout_router.rb in cli-ui-1.3.0 vs lib/cli/ui/stdout_router.rb in cli-ui-1.4.0
- old
+ new
@@ -24,18 +24,19 @@
@pending_newline = false
str
end
end
- hook = Thread.current[:cliui_output_hook]
# hook return of false suppresses output.
- if !hook || hook.call(args.first, @name) != false
- @stream.write_without_cli_ui(*prepend_id(@stream, args))
- if dup = StdoutRouter.duplicate_output_to
- dup.write(*prepend_id(dup, args))
- end
+ if (hook = Thread.current[:cliui_output_hook])
+ return if hook.call(args.map(&:to_s).join, @name) == false
end
+
+ @stream.write_without_cli_ui(*prepend_id(@stream, args))
+ if (dup = StdoutRouter.duplicate_output_to)
+ dup.write(*prepend_id(dup, args))
+ end
end
private
def prepend_id(stream, args)
@@ -115,10 +116,14 @@
err = StringIO.new
prev_frame_inset = Thread.current[:no_cliui_frame_inset]
prev_hook = Thread.current[:cliui_output_hook]
+ if Thread.current.respond_to?(:report_on_exception)
+ Thread.current.report_on_exception = false
+ end
+
self.class.with_stdin_masked do
Thread.current[:no_cliui_frame_inset] = !@with_frame_inset
Thread.current[:cliui_output_hook] = ->(data, stream) do
case stream
when :stdout then out.write(data)
@@ -157,10 +162,10 @@
require 'securerandom'
id = format("%05d", rand(10**5))
Thread.current[:cliui_output_id] = {
id: id,
- streams: on_streams
+ streams: on_streams,
}
yield(id)
ensure
Thread.current[:cliui_output_id] = nil
end