You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

113 lines
2.8 KiB

10 months ago
7 months ago
10 months ago
7 months ago
10 months ago
7 months ago
10 months ago
7 months ago
10 months ago
7 months ago
10 months ago
7 months ago
10 months ago
7 months ago
10 months ago
7 months ago
10 months ago
7 months ago
10 months ago
7 months ago
10 months ago
7 months ago
10 months ago
7 months ago
10 months ago
7 months ago
10 months ago
7 months ago
10 months ago
7 months ago
10 months ago
7 months ago
  1. #!/usr/bin/env ruby3.1
  2. # frozen_string_literal: true
  3. #
  4. # This file was generated by Bundler.
  5. #
  6. # The application 'bundle' is installed as part of a gem, and
  7. # this file is here to facilitate running it.
  8. #
  9. require 'rubygems'
  10. m = Module.new do
  11. module_function
  12. def invoked_as_script?
  13. File.expand_path($0) == File.expand_path(__FILE__)
  14. end
  15. def env_var_version
  16. ENV.fetch('BUNDLER_VERSION', nil)
  17. end
  18. def cli_arg_version
  19. return unless invoked_as_script? # don't want to hijack other binstubs
  20. return unless 'update'.start_with?(ARGV.first || ' ') # must be running `bundle update`
  21. bundler_version = nil
  22. update_index = nil
  23. ARGV.each_with_index do |a, i|
  24. bundler_version = a if update_index && update_index.succ == i && a.match?(Gem::Version::ANCHORED_VERSION_PATTERN)
  25. next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
  26. bundler_version = Regexp.last_match(1)
  27. update_index = i
  28. end
  29. bundler_version
  30. end
  31. def gemfile
  32. gemfile = ENV.fetch('BUNDLE_GEMFILE', nil)
  33. return gemfile if gemfile && !gemfile.empty?
  34. File.expand_path('../Gemfile', __dir__)
  35. end
  36. def lockfile
  37. lockfile =
  38. case File.basename(gemfile)
  39. when 'gems.rb' then gemfile.sub(/\.rb$/, '.locked')
  40. else "#{gemfile}.lock"
  41. end
  42. File.expand_path(lockfile)
  43. end
  44. def lockfile_version
  45. return unless File.file?(lockfile)
  46. lockfile_contents = File.read(lockfile)
  47. return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
  48. Regexp.last_match(1)
  49. end
  50. def bundler_requirement
  51. @bundler_requirement ||=
  52. env_var_version ||
  53. cli_arg_version ||
  54. bundler_requirement_for(lockfile_version)
  55. end
  56. def bundler_requirement_for(version)
  57. return "#{Gem::Requirement.default}.a" unless version
  58. bundler_gem_version = Gem::Version.new(version)
  59. bundler_gem_version.approximate_recommendation
  60. end
  61. def load_bundler!
  62. ENV['BUNDLE_GEMFILE'] ||= gemfile
  63. activate_bundler
  64. end
  65. def activate_bundler
  66. gem_error = activation_error_handling do
  67. gem 'bundler', bundler_requirement
  68. end
  69. return if gem_error.nil?
  70. require_error = activation_error_handling do
  71. require 'bundler/version'
  72. end
  73. if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION))
  74. return
  75. end
  76. warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`"
  77. exit 42
  78. end
  79. def activation_error_handling
  80. yield
  81. nil
  82. rescue StandardError, LoadError => e
  83. e
  84. end
  85. end
  86. m.load_bundler!
  87. load Gem.bin_path('bundler', 'bundle') if m.invoked_as_script?