Skip to content

Commit f4f43e2

Browse files
committed
Update binstubs.
1 parent 38ef846 commit f4f43e2

File tree

4 files changed

+21
-32
lines changed

4 files changed

+21
-32
lines changed

Diff for: bin/bundle

+12-17
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ m = Module.new do
2727
bundler_version = nil
2828
update_index = nil
2929
ARGV.each_with_index do |a, i|
30-
if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
30+
if update_index && update_index.succ == i && a.match?(Gem::Version::ANCHORED_VERSION_PATTERN)
3131
bundler_version = a
3232
end
3333
next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
@@ -41,13 +41,13 @@ m = Module.new do
4141
gemfile = ENV["BUNDLE_GEMFILE"]
4242
return gemfile if gemfile && !gemfile.empty?
4343

44-
File.expand_path("../../Gemfile", __FILE__)
44+
File.expand_path("../Gemfile", __dir__)
4545
end
4646

4747
def lockfile
4848
lockfile =
4949
case File.basename(gemfile)
50-
when "gems.rb" then gemfile.sub(/\.rb$/, gemfile)
50+
when "gems.rb" then gemfile.sub(/\.rb$/, ".locked")
5151
else "#{gemfile}.lock"
5252
end
5353
File.expand_path(lockfile)
@@ -60,24 +60,19 @@ m = Module.new do
6060
Regexp.last_match(1)
6161
end
6262

63-
def bundler_version
64-
@bundler_version ||=
65-
env_var_version || cli_arg_version ||
66-
lockfile_version
67-
end
68-
6963
def bundler_requirement
70-
return "#{Gem::Requirement.default}.a" unless bundler_version
71-
72-
bundler_gem_version = Gem::Version.new(bundler_version)
73-
74-
requirement = bundler_gem_version.approximate_recommendation
64+
@bundler_requirement ||=
65+
env_var_version ||
66+
cli_arg_version ||
67+
bundler_requirement_for(lockfile_version)
68+
end
7569

76-
return requirement unless Gem::Version.new(Gem::VERSION) < Gem::Version.new("2.7.0")
70+
def bundler_requirement_for(version)
71+
return "#{Gem::Requirement.default}.a" unless version
7772

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

80-
requirement
75+
bundler_gem_version.approximate_recommendation
8176
end
8277

8378
def load_bundler!

Diff for: bin/rake

+3-5
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,12 @@
88
# this file is here to facilitate running it.
99
#
1010

11-
require "pathname"
12-
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13-
Pathname.new(__FILE__).realpath)
11+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
1412

15-
bundle_binstub = File.expand_path("../bundle", __FILE__)
13+
bundle_binstub = File.expand_path("bundle", __dir__)
1614

1715
if File.file?(bundle_binstub)
18-
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
16+
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
1917
load(bundle_binstub)
2018
else
2119
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.

Diff for: bin/thor

+3-5
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,12 @@
88
# this file is here to facilitate running it.
99
#
1010

11-
require "pathname"
12-
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13-
Pathname.new(__FILE__).realpath)
11+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
1412

15-
bundle_binstub = File.expand_path("../bundle", __FILE__)
13+
bundle_binstub = File.expand_path("bundle", __dir__)
1614

1715
if File.file?(bundle_binstub)
18-
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
16+
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
1917
load(bundle_binstub)
2018
else
2119
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.

Diff for: bin/vim-flavor

+3-5
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,12 @@
88
# this file is here to facilitate running it.
99
#
1010

11-
require "pathname"
12-
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13-
Pathname.new(__FILE__).realpath)
11+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
1412

15-
bundle_binstub = File.expand_path("../bundle", __FILE__)
13+
bundle_binstub = File.expand_path("bundle", __dir__)
1614

1715
if File.file?(bundle_binstub)
18-
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
16+
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
1917
load(bundle_binstub)
2018
else
2119
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.

0 commit comments

Comments
 (0)