diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index ad2c7c969ca..c591884263e 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -618,6 +618,8 @@ def inject(name, version) "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 f4997b06200..d99ddaf294b 100644 --- a/spec/commands/lock_spec.rb +++ b/spec/commands/lock_spec.rb @@ -89,6 +89,33 @@ def read_lockfile(file = "Gemfile.lock") 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"