Permalink
Browse files

Add --skip-install flag to bundle add

  • Loading branch information...
agrim123 committed Apr 30, 2018
1 parent 9487710 commit 9e87a1ca4b0c3002ac2774e4837234cef7e3ce08
Showing with 13 additions and 2 deletions.
  1. +2 −1 lib/bundler/cli.rb
  2. +1 −1 lib/bundler/cli/add.rb
  3. +10 −0 spec/commands/add_spec.rb
View
@@ -333,7 +333,8 @@ def binstubs(*gems)
method_option "version", :aliases => "-v", :type => :string
method_option "group", :aliases => "-g", :type => :string
method_option "source", :aliases => "-s", :type => :string
method_option "skip-install", :type => :boolean, :banner =>
"Adds gem to gemfile but does not install it"
def add(gem_name)
require "bundler/cli/add"
Add.new(options.dup, gem_name).run
View
@@ -19,7 +19,7 @@ def run
dependency = Bundler::Dependency.new(@gem_name, version, @options)
Injector.inject([dependency], :conservative_versioning => @options[:version].nil?) # Perform conservative versioning only when version is not specified
Installer.install(Bundler.root, Bundler.definition)
Installer.install(Bundler.root, Bundler.definition) unless @options["skip-install"]
end
end
end
View
@@ -75,11 +75,21 @@
describe "with --source" do
it "adds dependency with specified source" do
bundle "add 'foo' --source='file://#{gem_repo2}'"
expect(bundled_app("Gemfile").read).to match(%r{gem "foo", "~> 2.0", :source => "file:\/\/#{gem_repo2}"})
expect(the_bundle).to include_gems "foo 2.0"
end
end
describe "with --skip-install" do
it "adds gem to Gemfile but is not installed" do
bundle "add foo --skip-install --version=2.0"
expect(bundled_app("Gemfile").read).to match(%r{gem "foo", "= 2.0"})
expect(the_bundle).to_not include_gems "foo 2.0"
end
end
it "using combination of short form options works like long form" do
bundle "add 'foo' -s='file://#{gem_repo2}' -g='development' -v='~>1.0'"
expect(bundled_app("Gemfile").read).to include %(gem "foo", "~> 1.0", :group => [:development], :source => "file://#{gem_repo2}")

0 comments on commit 9e87a1c

Please sign in to comment.