diff options
author | David RodrÃguez <deivid.rodriguez@riseup.net> | 2019-09-23 22:41:09 +0200 |
---|---|---|
committer | David RodrÃguez <deivid.rodriguez@riseup.net> | 2019-09-23 22:41:09 +0200 |
commit | 751641649580f544e92311e1aafeea8e158a36e1 (patch) | |
tree | 6755ea57c2fa1da3abf313020e5c58c03ab39ff5 /lib | |
parent | 3260d5994ec33bfaf81162c61d0d20bfff023375 (diff) | |
download | bundler-751641649580f544e92311e1aafeea8e158a36e1.tar.gz |
Add caller information to some deprecation messagesadd_info_to_some_deprecation_messages
Some deprecations would be fixed more easily if they included the
location where the deprecated method was called.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/bundler.rb | 14 | ||||
-rw-r--r-- | lib/bundler/shared_helpers.rb | 7 |
2 files changed, 15 insertions, 6 deletions
diff --git a/lib/bundler.rb b/lib/bundler.rb index a21dc7726d..4321a7ed3d 100644 --- a/lib/bundler.rb +++ b/lib/bundler.rb @@ -116,7 +116,7 @@ module Bundler end def environment - SharedHelpers.major_deprecation 2, "Bundler.environment has been removed in favor of Bundler.load" + SharedHelpers.major_deprecation 2, "Bundler.environment has been removed in favor of Bundler.load", :print_caller_location => true load end @@ -282,7 +282,8 @@ EOF Bundler::SharedHelpers.major_deprecation( 2, "`Bundler.clean_env` has been deprecated in favor of `Bundler.unbundled_env`. " \ - "If you instead want the environment before bundler was originally loaded, use `Bundler.original_env`" + "If you instead want the environment before bundler was originally loaded, use `Bundler.original_env`", + :print_caller_location => true ) unbundled_env @@ -321,7 +322,8 @@ EOF Bundler::SharedHelpers.major_deprecation( 2, "`Bundler.with_clean_env` has been deprecated in favor of `Bundler.with_unbundled_env`. " \ - "If you instead want the environment before bundler was originally loaded, use `Bundler.with_original_env`" + "If you instead want the environment before bundler was originally loaded, use `Bundler.with_original_env`", + :print_caller_location => true ) with_env(unbundled_env) { yield } @@ -342,7 +344,8 @@ EOF Bundler::SharedHelpers.major_deprecation( 2, "`Bundler.clean_system` has been deprecated in favor of `Bundler.unbundled_system`. " \ - "If you instead want to run the command in the environment before bundler was originally loaded, use `Bundler.original_system`" + "If you instead want to run the command in the environment before bundler was originally loaded, use `Bundler.original_system`", + :print_caller_location => true ) with_env(unbundled_env) { Kernel.system(*args) } @@ -363,7 +366,8 @@ EOF Bundler::SharedHelpers.major_deprecation( 2, "`Bundler.clean_exec` has been deprecated in favor of `Bundler.unbundled_exec`. " \ - "If you instead want to exec to a command in the environment before bundler was originally loaded, use `Bundler.original_exec`" + "If you instead want to exec to a command in the environment before bundler was originally loaded, use `Bundler.original_exec`", + :print_caller_location => true ) with_env(unbundled_env) { Kernel.exec(*args) } diff --git a/lib/bundler/shared_helpers.rb b/lib/bundler/shared_helpers.rb index e6e2b79344..dc44f8345c 100644 --- a/lib/bundler/shared_helpers.rb +++ b/lib/bundler/shared_helpers.rb @@ -124,7 +124,12 @@ module Bundler namespace.const_get(constant_name) end - def major_deprecation(major_version, message) + def major_deprecation(major_version, message, print_caller_location: false) + if print_caller_location + caller_location = caller_locations(2, 2).first + message = "#{message} (called at #{caller_location.path}:#{caller_location.lineno})" + end + bundler_major_version = Bundler.bundler_major_version if bundler_major_version > major_version require_relative "errors" |