summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThe Bundler Bot <bot@bundler.io>2018-04-19 11:57:18 +0000
committerColby Swandale <me@colby.fyi>2018-10-09 22:32:27 +1100
commit5567879d36bc6bfd5f23c6dfd871599c6ed79169 (patch)
tree6712e9bab8138b5820f92690945071c404ae6c66
parentaad374a88a5d7bd8a5d5a458294a9a411b323016 (diff)
downloadbundler-5567879d36bc6bfd5f23c6dfd871599c6ed79169.tar.gz
Auto merge of #6450 - bundler:segiddins/bundle-binstubs-all, r=colby-swandale
[Binstubs] Add --all options ### What was the end-user problem that led to this PR? The problem was we have removed the `--binstubs` argument to `bundle install`, so saying "oh well, lets install all the bin stubs" became more tedious, requiring multiple calls to `bundle binstubs` and probably some swearing since you forgot what gem contains what binstub. ### What was your diagnosis of the problem? My diagnosis was we need a one-liner to generate bin stubs for all gems. ### What is your fix for the problem, implemented in this PR? My fix adds such an option to `bundle binstubs`! ### Why did you choose this fix out of the possible options? I chose this fix because it keeps binstub generation in its own command, rather than continuing to piggy-back off of `install` (cherry picked from commit e5c06862a620b8e0bc778164f0e426f927c10cba)
-rw-r--r--lib/bundler/cli.rb2
-rw-r--r--lib/bundler/cli/binstubs.rb10
-rw-r--r--spec/commands/binstubs_spec.rb23
3 files changed, 33 insertions, 2 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb
index 2aa1b227ab..fda09dd0eb 100644
--- a/lib/bundler/cli.rb
+++ b/lib/bundler/cli.rb
@@ -321,6 +321,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 f6a353cb4d..ec73770c27 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