summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Giddins <segiddins@segiddins.me>2017-07-20 12:31:42 -0500
committerSamuel Giddins <segiddins@segiddins.me>2017-07-21 09:33:01 -0500
commit12e904fa801c04279331ad2cb7b6c12c7c392733 (patch)
tree6c0561a6ff45097d4227af35e18fbb4af256d1ae
parent39898f4c8de84304c3755ec602ec39d5fd8a7184 (diff)
downloadbundler-12e904fa801c04279331ad2cb7b6c12c7c392733.tar.gz
Re-format the bundle binstub to conform to Bundler standard
-rw-r--r--lib/bundler/templates/Executable.bundler29
1 files changed, 19 insertions, 10 deletions
diff --git a/lib/bundler/templates/Executable.bundler b/lib/bundler/templates/Executable.bundler
index a9103ff6bd..085955c7a9 100644
--- a/lib/bundler/templates/Executable.bundler
+++ b/lib/bundler/templates/Executable.bundler
@@ -11,29 +11,38 @@
require "rubygems"
m = Module.new do
- module_function
+ module_function
+
+ def invoked_as_script?
+ File.expand_path($0) == File.expand_path(__FILE__)
+ end
def env_var_version
- ENV['BUNDLER_VERSION']
+ ENV["BUNDLER_VERSION"]
end
def cli_arg_version
- update = "update".start_with?(ARGV.first || " ") && ARGV.find {|a| a.start_with?("--bundler") }
- update &&= update =~ /--bundler(?:=(.+))?/ && $1 || "> 0.a"
+ return unless invoked_as_script? # don't want to hijack other binstubs
+ return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
+ return unless update = ARGV.find {|a| a.start_with?("--bundler") } # must have a --bundler arg
+ return unless update =~ /--bundler(?:=(.+))?/
+ $1 || ">= 0.a"
end
def gemfile
- gemfile = ENV['BUNDLE_GEMFILE']
+ gemfile = ENV["BUNDLE_GEMFILE"]
return gemfile if gemfile && !gemfile.empty?
File.expand_path("../<%= relative_gemfile_path %>", __FILE__)
end
def lockfile
- File.expand_path case File.basename(gemfile)
- when 'gems.rb' then gemfile.sub(/\.rb$/, gemfile)
- else "#{gemfile}.lock"
- end
+ lockfile =
+ case File.basename(gemfile)
+ when "gems.rb" then gemfile.sub(/\.rb$/, gemfile)
+ else "#{gemfile}.lock"
+ end
+ File.expand_path(lockfile)
end
def lockfile_version
@@ -79,6 +88,6 @@ end
m.load_bundler!
-if File.expand_path($0) == File.expand_path(__FILE__)
+if m.invoked_as_script?
load Gem.bin_path("<%= spec.name %>", "<%= executable %>")
end