summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2018-09-26 14:26:07 -0300
committerDavid Rodríguez <deivid.rodriguez@riseup.net>2020-03-09 18:25:09 +0100
commit06c585dfb69d256c985536aeba0335d6437d7aad (patch)
tree910b08ac49809a5f676591fc49eb2c8df41bad1a
parentdaa04db90e7d55c5ad7c1501f38cf718c62061f4 (diff)
downloadbundler-06c585dfb69d256c985536aeba0335d6437d7aad.tar.gz
Move some logic to helper
-rw-r--r--lib/bundler.rb8
-rw-r--r--lib/bundler/shared_helpers.rb8
2 files changed, 7 insertions, 9 deletions
diff --git a/lib/bundler.rb b/lib/bundler.rb
index 0d9a523310..93093f2e32 100644
--- a/lib/bundler.rb
+++ b/lib/bundler.rb
@@ -274,13 +274,7 @@ module Bundler
end
def root
- @root ||= begin
- SharedHelpers.root
- rescue GemfileNotFound
- bundle_dir = default_bundle_dir
- raise GemfileNotFound, "Could not locate Gemfile or .bundle/ directory" unless bundle_dir
- bundle_dir.parent
- end
+ @root ||= SharedHelpers.root
end
def app_config_path
diff --git a/lib/bundler/shared_helpers.rb b/lib/bundler/shared_helpers.rb
index 6e83bc5ff4..94e6875f00 100644
--- a/lib/bundler/shared_helpers.rb
+++ b/lib/bundler/shared_helpers.rb
@@ -12,8 +12,12 @@ module Bundler
module SharedHelpers
def root
gemfile = find_gemfile
- raise GemfileNotFound, "Could not locate Gemfile" unless gemfile
- Pathname.new(gemfile).tap{|x| x.untaint if RUBY_VERSION < "2.7" }.expand_path.parent
+ return Pathname.new(gemfile).tap{|x| x.untaint if RUBY_VERSION < "2.7" }.expand_path.parent if gemfile
+
+ bundle_dir = default_bundle_dir
+ raise GemfileNotFound, "Could not locate Gemfile or .bundle/ directory" unless bundle_dir
+
+ bundle_dir.parent
end
def default_gemfile