summaryrefslogtreecommitdiff
path: root/lib/bundler/settings/validator.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/bundler/settings/validator.rb')
-rw-r--r--lib/bundler/settings/validator.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/bundler/settings/validator.rb b/lib/bundler/settings/validator.rb
index 9aa1627fb2..0a57ea7f03 100644
--- a/lib/bundler/settings/validator.rb
+++ b/lib/bundler/settings/validator.rb
@@ -74,6 +74,29 @@ module Bundler
fail!(key, value, "`#{other_key}` is current set to #{other_setting.inspect}", "the `#{conflicting.join("`, `")}` groups conflict")
end
end
+
+ rule %w[path], "relative paths are expanded relative to the current working directory" do |key, value, settings|
+ next if value.nil?
+
+ path = Pathname.new(value)
+ next if !path.relative? || !Bundler.feature_flag.path_relative_to_cwd?
+
+ path = path.expand_path
+
+ root = begin
+ Bundler.root
+ rescue GemfileNotFound
+ Pathname.pwd.expand_path
+ end
+
+ path = begin
+ path.relative_path_from(root)
+ rescue ArgumentError
+ path
+ end
+
+ set(settings, key, path.to_s)
+ end
end
end
end