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

Add --shebang option to binstubs command #4070

Merged
merged 1 commit into from
Oct 25, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ The `bundler/capistrano` and `bundler/vlad` deployment helper files have been re

The `--binstubs` option has been removed from `bundle install` and replaced with the `bundle binstubs` command. This means that binstubs must be created and checked into version control individually.

The `bundle binstubs [GEM]` command accepts two optional arguments: `--force`, which overwrites existing binstubs if they exist, and `--path=PATH`, which specifies the directory in which the binstubs will be installed (`./bin` by default).
The `bundle binstubs [GEM]` command accepts three optional arguments: `--force`, which overwrites existing binstubs if they exist, `--path=PATH` which specifies the directory in which the binstubs will be installed (`./bin` by default) and `--shebang=RUBY_EXECUTABLE`, which sets the shebang executable name for the installed binstubs.
2 changes: 2 additions & 0 deletions lib/bundler/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ def show(gem_name = nil)
D
method_option "force", :type => :boolean, :default => false, :banner =>
"Overwrite existing binstubs if they exist"
method_option "shebang", :type => :string, :banner =>
"Specify a different shebang executable name than the default (usually 'ruby')"
def binstubs(*gems)
require "bundler/cli/binstubs"
Binstubs.new(options, gems).run
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 @@ -12,6 +12,7 @@ def run
Bundler.definition.validate_ruby!
Bundler.settings[:bin] = Bundler.settings["path.binstubs"] if Bundler.settings["path.binstubs"]
Bundler.settings[:bin] = nil if Bundler.settings["path.binstubs"] && Bundler.settings["path.binstubs"].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