diff options
author | The Bundler Bot <bot@bundler.io> | 2017-06-16 17:19:39 +0000 |
---|---|---|
committer | The Bundler Bot <bot@bundler.io> | 2017-06-16 17:19:39 +0000 |
commit | 1ce5c35faee7004ccf723d090cdd796d6f79a6f9 (patch) | |
tree | f074d022bd6fdcd36a6ea506aa3de4131dfa1307 | |
parent | d4a06723f2552f55bc46b395ab1cc0070b438b7e (diff) | |
parent | f619a9c944fedf2bd50029426eb698dbb0e2118f (diff) | |
download | bundler-1ce5c35faee7004ccf723d090cdd796d6f79a6f9.tar.gz |
Auto merge of #5721 - bundler:seg-binstubs-shebang, r=indirect
Add --shebang option to binstubs command
Ports https://github.com/bundler/bundler/pull/4070 to master.
bundle install `--binstubs` option is to be removed from Bundler 2.0 but
currently supports setting the shebang using the `--shebang` option.
See #1467 introducing the `--shebang` option, which with this commit
is ported to the binstubs command.
-rw-r--r-- | lib/bundler/cli.rb | 2 | ||||
-rw-r--r-- | lib/bundler/cli/binstubs.rb | 1 | ||||
-rw-r--r-- | spec/commands/binstubs_spec.rb | 13 |
3 files changed, 16 insertions, 0 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index 0c89e41656..838dcb3e08 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -262,6 +262,8 @@ module Bundler "Overwrite existing binstubs if they exist" method_option "path", :type => :string, :lazy_default => "bin", :banner => "Binstub destination directory (default bin)" + method_option "shebang", :type => :string, :banner => + "Specify a different shebang executable name than the default (usually 'ruby')" method_option "standalone", :type => :boolean, :banner => "Make binstubs that can work without the Bundler runtime" def binstubs(*gems) diff --git a/lib/bundler/cli/binstubs.rb b/lib/bundler/cli/binstubs.rb index 82815062d3..f872a2dcc7 100644 --- a/lib/bundler/cli/binstubs.rb +++ b/lib/bundler/cli/binstubs.rb @@ -13,6 +13,7 @@ module Bundler Bundler.definition.validate_runtime! Bundler.settings[:bin] = options["path"] if options["path"] Bundler.settings[:bin] = nil if options["path"] && options["path"].empty? + Bundler.settings[:shebang] = options["shebang"] if options["shebang"] installer = Installer.new(Bundler.root, Bundler.definition) if gems.empty? diff --git a/spec/commands/binstubs_spec.rb b/spec/commands/binstubs_spec.rb index f3ca2301a7..430dbef314 100644 --- a/spec/commands/binstubs_spec.rb +++ b/spec/commands/binstubs_spec.rb @@ -103,6 +103,19 @@ RSpec.describe "bundle binstubs <gem>" do expect(File.stat(binary).mode.to_s(8)).to eq("100775") end end + + context "when using --shebang" do + it "sets the specified shebang for the the binstub" do + install_gemfile <<-G + source "file://#{gem_repo1}" + gem "rack" + G + + bundle "binstubs rack --shebang jruby" + + expect(File.open("bin/rackup").gets).to eq("#!/usr/bin/env jruby\n") + end + end end context "when the gem doesn't exist" do |