Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Commit

Permalink
Auto merge of #5721 - bundler:seg-binstubs-shebang, r=indirect
Browse files Browse the repository at this point in the history
Add --shebang option to binstubs command

Ports #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.
  • Loading branch information
bundlerbot committed Jun 16, 2017
2 parents d4a0672 + f619a9c commit 1ce5c35
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/bundler/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,8 @@ def info(gem_name)
"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)
Expand Down
1 change: 1 addition & 0 deletions lib/bundler/cli/binstubs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def run
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?
Expand Down
13 changes: 13 additions & 0 deletions spec/commands/binstubs_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,19 @@
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
Expand Down

0 comments on commit 1ce5c35

Please sign in to comment.