diff options
author | André Arko <andre@arko.net> | 2013-08-01 13:17:22 -0700 |
---|---|---|
committer | André Arko <andre@arko.net> | 2013-08-01 13:17:22 -0700 |
commit | cadc77ae568ace9e4f091b809975dbb78bd5f40a (patch) | |
tree | e139fdc1d05f87436ef35f1668f163bae58d5632 | |
parent | a20d093954c5693cefef9418316286ff8e0fed38 (diff) | |
parent | a6c248b09db12ae9f5fd534eaa41ba97bd52e64e (diff) | |
download | bundler-cadc77ae568ace9e4f091b809975dbb78bd5f40a.tar.gz |
Merge pull request #2576 from lucasmazza/multiple-binstubs
Add support for multiple gems in `bundle binstubs`
-rw-r--r-- | lib/bundler/cli.rb | 22 | ||||
-rw-r--r-- | spec/other/binstubs_spec.rb | 24 |
2 files changed, 39 insertions, 7 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index 137a3e13f7..68375068d3 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -379,18 +379,26 @@ module Bundler "binstub destination directory (default bin)" method_option "force", :type => :boolean, :default => false, :banner => "overwrite existing binstubs if they exist" - def binstubs(gem_name) + def binstubs(*gems) Bundler.definition.validate_ruby! Bundler.settings[:bin] = options["path"] if options["path"] Bundler.settings[:bin] = nil if options["path"] && options["path"].empty? installer = Installer.new(Bundler.root, Bundler.definition) - spec = installer.specs.find{|s| s.name == gem_name } - raise GemNotFound, not_found_message(gem_name, Bundler.definition.specs) unless spec - if spec.name == "bundler" - Bundler.ui.warn "Sorry, Bundler can only be run via Rubygems." - else - installer.generate_bundler_executable_stubs(spec, :force => options[:force], :binstubs_cmd => true) + if gems.empty? + Bundler.ui.error "`bundle binstubs` needs at least one gem to run." + exit 1 + end + + gems.each do |gem_name| + spec = installer.specs.find{|s| s.name == gem_name } + raise GemNotFound, not_found_message(gem_name, Bundler.definition.specs) unless spec + + if spec.name == "bundler" + Bundler.ui.warn "Sorry, Bundler can only be run via Rubygems." + else + installer.generate_bundler_executable_stubs(spec, :force => options[:force], :binstubs_cmd => true) + end end end diff --git a/spec/other/binstubs_spec.rb b/spec/other/binstubs_spec.rb index 9237a8d3d5..3d3ed0fc58 100644 --- a/spec/other/binstubs_spec.rb +++ b/spec/other/binstubs_spec.rb @@ -26,6 +26,30 @@ describe "bundle binstubs <gem>" do expect(bundled_app("bin/rails")).to exist end + it "does install multiple binstubs" do + install_gemfile <<-G + source "file://#{gem_repo1}" + gem "rack" + gem "rails" + G + + bundle "binstubs rails rack" + + expect(bundled_app("bin/rackup")).to exist + expect(bundled_app("bin/rails")).to exist + end + + it "displays an error when used without any gem" do + install_gemfile <<-G + source "file://#{gem_repo1}" + gem "rack" + G + + bundle "binstubs", :exitstatus => true + expect(exitstatus).to eq(1) + expect(out).to eq("`bundle binstubs` needs at least one gem to run.") + end + it "does not bundle the bundler binary" do install_gemfile <<-G source "file://#{gem_repo1}" |