Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Add --skip-install flag to bundle add #6517

Merged
merged 2 commits into from May 20, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/bundler/cli.rb
Expand Up @@ -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 the Gemfile but does not install it"
def add(gem_name)
require "bundler/cli/add"
Add.new(options.dup, gem_name).run
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/cli/add.rb
Expand Up @@ -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
9 changes: 7 additions & 2 deletions man/bundle-add.ronn
Expand Up @@ -3,10 +3,10 @@ bundle-add(1) -- Add gem to the Gemfile and run bundle install

## SYNOPSIS

`bundle add` <GEM_NAME> [--group=GROUP] [--version=VERSION] [--source=SOURCE]
`bundle add` <GEM_NAME> [--group=GROUP] [--version=VERSION] [--source=SOURCE] [--skip-install]

## DESCRIPTION
Adds the named gem to the Gemfile and run `bundle install`.
Adds the named gem to the Gemfile and run `bundle install`. `bundle install` can be avoided by using the flag `--skip-install`.

Example:

Expand All @@ -16,6 +16,8 @@ bundle add rails --version "< 3.0, > 1.1"

bundle add rails --version "~> 5.0.0" --source "https://gems.example.com" --group "development"

bundle add rails --skip-install

bundle add rails --group "development, test"

## OPTIONS
Expand All @@ -27,3 +29,6 @@ bundle add rails --group "development, test"

* `--source`, , `-s`:
Specify the source for the added gem.

* `--skip-install`:
Adds the gem to the Gemfile but does not install it.
10 changes: 10 additions & 0 deletions spec/commands/add_spec.rb
Expand Up @@ -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(/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}")
Expand Down