diff options
author | Bundlerbot <bot@bundler.io> | 2018-10-18 09:54:20 +0000 |
---|---|---|
committer | Bundlerbot <bot@bundler.io> | 2018-10-18 09:54:20 +0000 |
commit | 9286063edcc55d720bbfdcf371e3ea96668cc020 (patch) | |
tree | 5f489013fafa7d632b34bb4199af24a0cb076f41 | |
parent | 18369b8a0999f11515e28603676f99ca376d7d93 (diff) | |
parent | 5bd3ef0901a053b8266026d0bc47ae66b4a9d8d9 (diff) | |
download | bundler-9286063edcc55d720bbfdcf371e3ea96668cc020.tar.gz |
Merge #6748
6748: Enable gemfile flag for bundle lock r=colby-swandale a=jekuta
### What was the end-user problem that led to this PR?
`bundle lock` does not accept the `--gemfile` flag that allows to define a custom Gemfile.
### What was your diagnosis of the problem?
The option is not defined as available.
### What is your fix for the problem, implemented in this PR?
Adds the option to the list available options for `lock` command.
I wasn't sure though, in which order to display this the new option. I just added it where it felt the most natural to me, but please let me know if there is a better order.
Also do you think it would make sense to add this flag to the other commands as well?
For example: `add`, `remove`, `console`, `outdated`, `clean`?
For now it is available for: `check`, `exec`, `install`, `update`, `package`, `doctor`.
### Why did you choose this fix out of the possible options?
I don't think there are any other options to implement this.
Closes #6735
Co-authored-by: Laura Paakkinen <laura.paakkinen@u2i.com>
-rw-r--r-- | lib/bundler/cli.rb | 2 | ||||
-rw-r--r-- | spec/commands/lock_spec.rb | 27 |
2 files changed, 29 insertions, 0 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index ad2c7c969c..c591884263 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -618,6 +618,8 @@ module Bundler "do not attempt to fetch remote gemspecs and use the local gem cache only" method_option "print", :type => :boolean, :default => false, :banner => "print the lockfile to STDOUT instead of writing to the file system" + method_option "gemfile", :type => :string, :banner => + "Use the specified gemfile instead of Gemfile" method_option "lockfile", :type => :string, :default => nil, :banner => "the path the lockfile should be written to" method_option "full-index", :type => :boolean, :default => false, :banner => diff --git a/spec/commands/lock_spec.rb b/spec/commands/lock_spec.rb index f4997b0620..d99ddaf294 100644 --- a/spec/commands/lock_spec.rb +++ b/spec/commands/lock_spec.rb @@ -89,6 +89,33 @@ RSpec.describe "bundle lock" do expect(out).to match(/sources listed in your Gemfile|installed locally/) end + it "works with --gemfile flag" do + create_file "CustomGemfile", <<-G + source "file://localhost#{repo}" + gem "foo" + G + lockfile = strip_lockfile(normalize_uri_file(<<-L)) + GEM + remote: file://localhost#{repo}/ + specs: + foo (1.0) + + PLATFORMS + #{lockfile_platforms} + + DEPENDENCIES + foo + + BUNDLED WITH + #{Bundler::VERSION} + L + bundle "lock --gemfile CustomGemfile" + + expect(out).to match(/Writing lockfile to.+CustomGemfile\.lock/) + expect(read_lockfile("CustomGemfile.lock")).to eq(lockfile) + expect { read_lockfile }.to raise_error(Errno::ENOENT) + end + it "writes to a custom location using --lockfile" do bundle "lock --lockfile=lock" |