diff options
author | Samuel Giddins <segiddins@segiddins.me> | 2016-02-24 20:23:44 -0600 |
---|---|---|
committer | Samuel Giddins <segiddins@segiddins.me> | 2016-02-24 20:23:44 -0600 |
commit | 8a06ca5f6e96636e9349617851dd1b0eb8af1bd8 (patch) | |
tree | 4dc4ab184d27a56c1139a593492436f9d5375ac0 /bin | |
parent | c1f6b0ca96a5593e99a7b9133aff88ade1e38918 (diff) | |
download | bundler-8a06ca5f6e96636e9349617851dd1b0eb8af1bd8.tar.gz |
Add helper script for running with particular rubygems versions
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/rake | 6 | ||||
-rwxr-xr-x | bin/rspec | 6 | ||||
-rwxr-xr-x | bin/rubocop | 6 | ||||
-rwxr-xr-x | bin/with_rubygems | 35 |
4 files changed, 44 insertions, 9 deletions
@@ -1,6 +1,8 @@ #!/usr/bin/env ruby # frozen_string_literal: true +load File.expand_path("../with_rubygems", __FILE__) if ENV["RGV"] + require "rubygems" bundler_spec = Gem::Specification.load(File.expand_path("../../bundler.gemspec", __FILE__)) @@ -12,8 +14,6 @@ bundler_spec.dependencies.each do |dep| end end -Gem::Specification.unresolved_deps.each do |_name, dep| - gem dep.name, *dep.requirement -end +Gem.finish_resolve if Gem.respond_to?(:finish_resolve) load Gem.bin_path("rake", "rake") @@ -1,6 +1,8 @@ #!/usr/bin/env ruby # frozen_string_literal: true +load File.expand_path("../with_rubygems", __FILE__) if ENV["RGV"] + require "rubygems" bundler_spec = Gem::Specification.load(File.expand_path("../../bundler.gemspec", __FILE__)) @@ -8,8 +10,6 @@ bundler_spec.dependencies.each do |dep| gem dep.name, dep.requirement.to_s end -Gem::Specification.unresolved_deps.each do |_name, dep| - gem dep.name, *dep.requirement -end +Gem.finish_resolve if Gem.respond_to?(:finish_resolve) load Gem.bin_path("rspec-core", "rspec") diff --git a/bin/rubocop b/bin/rubocop index bc81f5cc88..01840861cc 100755 --- a/bin/rubocop +++ b/bin/rubocop @@ -1,6 +1,8 @@ #!/usr/bin/env ruby # frozen_string_literal: true +load File.expand_path("../with_rubygems", __FILE__) if ENV["RGV"] + require "rubygems" bundler_spec = Gem::Specification.load(File.expand_path("../../bundler.gemspec", __FILE__)) @@ -10,8 +12,6 @@ end gem "rubocop", "= 0.37.1" -Gem::Specification.unresolved_deps.each do |_name, dep| - gem dep.name, *dep.requirement -end +Gem.finish_resolve if Gem.respond_to?(:finish_resolve) load Gem.bin_path("rubocop", "rubocop") diff --git a/bin/with_rubygems b/bin/with_rubygems new file mode 100755 index 0000000000..666467b1e5 --- /dev/null +++ b/bin/with_rubygems @@ -0,0 +1,35 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +require "pathname" + +def run(*cmd) + return if system(*cmd) + raise "Running `#{cmd.join(" ")}` failed" +end + +version = ENV.delete("RGV") +rubygems_path = Pathname.new(__FILE__).join("../../tmp/rubygems").expand_path +unless rubygems_path.directory? + rubygems_path.parent.mkpath unless rubygems_path.directory? + run("git", "clone", "https://github.com/rubygems/rubygems.git", rubygems_path.to_s) +end +Dir.chdir(rubygems_path) do + version = "v#{version}" if version =~ /\A\d/ + run("git", "checkout", version, "--quiet") +end if version + +ENV["RUBYOPT"] = %(-I#{rubygems_path + "lib"} #{ENV["RUBYOPT"]}) +if cmd = ARGV.first + possible_dirs = [ + Pathname.new(__FILE__) + "..", + Pathname.new(__FILE__) + "../../exe", + rubygems_path + "bin", + ] + cmd = possible_dirs.map do |dir| + dir.join(cmd).expand_path + end.find(&:file?) + ARGV[0] = cmd.to_s if cmd +end + +exec(*ARGV) if $0 == __FILE__ |