diff options
author | Samuel Giddins <segiddins@segiddins.me> | 2018-03-20 20:54:41 -0700 |
---|---|---|
committer | Samuel Giddins <segiddins@segiddins.me> | 2018-04-18 20:50:40 -0700 |
commit | ecda83c37afb8799eb5228fc3fa1015f0dc8c99b (patch) | |
tree | 22f8cfb9e1bd4e21c3a226f4bf925bc0d9c7718e | |
parent | bbd0b49aa2260de17b697a21f2bb932959284c5c (diff) | |
download | bundler-ecda83c37afb8799eb5228fc3fa1015f0dc8c99b.tar.gz |
[Binstubs] Add --all optionssegiddins/bundle-binstubs-all
-rw-r--r-- | lib/bundler/cli.rb | 2 | ||||
-rw-r--r-- | lib/bundler/cli/binstubs.rb | 10 | ||||
-rw-r--r-- | spec/commands/binstubs_spec.rb | 23 |
3 files changed, 33 insertions, 2 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index d86441f5ae..1b913024e2 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -319,6 +319,8 @@ module Bundler "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 diff --git a/lib/bundler/cli/binstubs.rb b/lib/bundler/cli/binstubs.rb index 449204d821..266396eedc 100644 --- a/lib/bundler/cli/binstubs.rb +++ b/lib/bundler/cli/binstubs.rb @@ -16,7 +16,13 @@ module Bundler 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 @@ -35,7 +41,7 @@ module Bundler 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 diff --git a/spec/commands/binstubs_spec.rb b/spec/commands/binstubs_spec.rb index 8157173b42..ad859a21d5 100644 --- a/spec/commands/binstubs_spec.rb +++ b/spec/commands/binstubs_spec.rb @@ -39,6 +39,18 @@ RSpec.describe "bundle binstubs <gem>" do 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}" @@ -50,6 +62,17 @@ RSpec.describe "bundle binstubs <gem>" do 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 |