Skip to content
This repository was archived by the owner on Apr 14, 2021. It is now read-only.
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: 2 additions & 0 deletions lib/bundler/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,8 @@ def info(gem_name)
"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"
method_option "all", :type => :boolean, :banner =>
"Install binstubs for all gems"
def binstubs(*gems)
require "bundler/cli/binstubs"
Binstubs.new(options, gems).run
Expand Down
10 changes: 8 additions & 2 deletions lib/bundler/cli/binstubs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ def run
Bundler.settings.set_command_option_if_given :shebang, options["shebang"]
installer = Installer.new(Bundler.root, Bundler.definition)

if gems.empty?
installer_opts = { :force => options[:force], :binstubs_cmd => true }

if options[:all]
raise InvalidOption, "Cannot specify --all with specific gems" unless gems.empty?
@gems = Bundler.definition.specs.map(&:name)
installer_opts.delete(:binstubs_cmd)
elsif gems.empty?
Bundler.ui.error "`bundle binstubs` needs at least one gem to run."
exit 1
end
Expand All @@ -35,7 +41,7 @@ def run
installer.generate_standalone_bundler_executable_stubs(spec)
end
else
installer.generate_bundler_executable_stubs(spec, :force => options[:force], :binstubs_cmd => true)
installer.generate_bundler_executable_stubs(spec, installer_opts)
end
end
end
Expand Down
23 changes: 23 additions & 0 deletions spec/commands/binstubs_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,18 @@
expect(bundled_app("bin/rails")).to exist
end

it "allows installing all binstubs" do
install_gemfile! <<-G
source "file://#{gem_repo1}"
gem "rails"
G

bundle! :binstubs, :all => true

expect(bundled_app("bin/rails")).to exist
expect(bundled_app("bin/rake")).to exist
end

it "displays an error when used without any gem" do
install_gemfile <<-G
source "file://#{gem_repo1}"
Expand All @@ -50,6 +62,17 @@
expect(out).to include("`bundle binstubs` needs at least one gem to run.")
end

it "displays an error when used with --all and gems" do
install_gemfile <<-G
source "file://#{gem_repo1}"
gem "rack"
G

bundle "binstubs rack", :all => true
expect(last_command).to be_failure
expect(last_command.bundler_err).to include("Cannot specify --all with specific gems")
end

context "when generating bundle binstub outside bundler" do
it "should abort" do
install_gemfile <<-G
Expand Down