Skip to content

Commit

Permalink
Update bundler binstub
Browse files Browse the repository at this point in the history
  • Loading branch information
n-rodriguez committed Feb 28, 2024
1 parent 7430091 commit df12330
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions bin/bundle
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ m = Module.new do
bundler_version = nil
update_index = nil
ARGV.each_with_index do |a, i|
if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
if update_index && update_index.succ == i && a.match?(Gem::Version::ANCHORED_VERSION_PATTERN)
bundler_version = a
end
next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
Expand All @@ -41,13 +41,13 @@ m = Module.new do
gemfile = ENV["BUNDLE_GEMFILE"]
return gemfile if gemfile && !gemfile.empty?

File.expand_path("../../Gemfile", __FILE__)
File.expand_path("../Gemfile", __dir__)
end

def lockfile
lockfile =
case File.basename(gemfile)
when "gems.rb" then gemfile.sub(/\.rb$/, gemfile)
when "gems.rb" then gemfile.sub(/\.rb$/, ".locked")
else "#{gemfile}.lock"
end
File.expand_path(lockfile)
Expand All @@ -60,24 +60,19 @@ m = Module.new do
Regexp.last_match(1)
end

def bundler_version
@bundler_version ||=
env_var_version || cli_arg_version ||
lockfile_version
end

def bundler_requirement
return "#{Gem::Requirement.default}.a" unless bundler_version

bundler_gem_version = Gem::Version.new(bundler_version)

requirement = bundler_gem_version.approximate_recommendation
@bundler_requirement ||=
env_var_version ||
cli_arg_version ||
bundler_requirement_for(lockfile_version)
end

return requirement unless Gem::Version.new(Gem::VERSION) < Gem::Version.new("2.7.0")
def bundler_requirement_for(version)
return "#{Gem::Requirement.default}.a" unless version

requirement += ".a" if bundler_gem_version.prerelease?
bundler_gem_version = Gem::Version.new(version)

requirement
bundler_gem_version.approximate_recommendation
end

def load_bundler!
Expand Down

0 comments on commit df12330

Please sign in to comment.