summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2019-08-10 23:59:16 +0200
committerDavid Rodríguez <deivid.rodriguez@riseup.net>2019-08-10 23:59:16 +0200
commit0d1f21a3b82bf456119f5603fea18e6761d52b90 (patch)
tree845871e4daa2a0d0971642506b3569c759014caa
parent7d0b27591bc6e7dc9a960f0f606203466811650f (diff)
downloadbundler-less_ui_silencing.tar.gz
-rw-r--r--lib/bundler/shared_helpers.rb25
1 files changed, 18 insertions, 7 deletions
diff --git a/lib/bundler/shared_helpers.rb b/lib/bundler/shared_helpers.rb
index da7dff44fe..62a292fcee 100644
--- a/lib/bundler/shared_helpers.rb
+++ b/lib/bundler/shared_helpers.rb
@@ -133,13 +133,9 @@ module Bundler
end
return unless bundler_major_version >= major_version && prints_major_deprecations?
-
- begin
- ui = Bundler.ui
- Bundler.ui = Bundler::UI::Shell.new("no-color" => true)
- Bundler.ui.warn("[DEPRECATED] #{message}")
- ensure
- Bundler.ui = ui
+ @major_deprecation_ui ||= Bundler::UI::Shell.new("no-color" => true)
+ with_major_deprecation_ui do |ui|
+ ui.warn("[DEPRECATED] #{message}")
end
end
@@ -217,6 +213,21 @@ module Bundler
private
+ def with_major_deprecation_ui(&block)
+ ui = Bundler.ui
+
+ if ui.is_a?(@major_deprecation_ui.class)
+ yield ui
+ else
+ begin
+ Bundler.ui = @major_deprecation_ui
+ yield Bundler.ui
+ ensure
+ Bundler.ui = ui
+ end
+ end
+ end
+
def validate_bundle_path
path_separator = Bundler.rubygems.path_separator
return unless Bundler.bundle_path.to_s.split(path_separator).size > 1