summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThe Bundler Bot <bot@bundler.io>2018-09-03 07:51:46 +0000
committerColby Swandale <me@colby.fyi>2018-09-23 00:15:45 +1000
commitba1f05be78eae3f36fd9401b140f4a11b7c75bf4 (patch)
treeae98ed872ccf5960d30f9631f5417083effcdd09
parent9f00dfab1c8d6439ad0d2d3befeb8d129ca1d775 (diff)
downloadbundler-ba1f05be78eae3f36fd9401b140f4a11b7c75bf4.tar.gz
Auto merge of #6676 - ankitkataria:gemfile-flag, r=colby-swandale
Add gemfile flag to exec command ### What was the end-user problem that led to this PR? This PR resolves the issue #5924 ### What was your diagnosis of the problem? - added a `gemfile` flag in `cli.rb` - if `options[:gemfile]` is set I created a SharedHelper method `custom_gemfile` which used the predefined `find_file` function to find and set the environment variable with the argument provided (cherry picked from commit c4892480aba36d31a3b6e232f17a705aaad1b730)
-rw-r--r--lib/bundler/cli.rb1
-rw-r--r--spec/commands/exec_spec.rb9
2 files changed, 10 insertions, 0 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb
index 394118b65f..c2831d8ea8 100644
--- a/lib/bundler/cli.rb
+++ b/lib/bundler/cli.rb
@@ -423,6 +423,7 @@ module Bundler
desc "exec [OPTIONS]", "Run the command in context of the bundle"
method_option :keep_file_descriptors, :type => :boolean, :default => false
+ method_option :gemfile, :type => :string, :required => false
long_desc <<-D
Exec runs a command, providing it access to the gems in the bundle. While using
bundle exec you can require and call the bundled gems as if they were installed
diff --git a/spec/commands/exec_spec.rb b/spec/commands/exec_spec.rb
index 03212fd9b3..bd3c49baa1 100644
--- a/spec/commands/exec_spec.rb
+++ b/spec/commands/exec_spec.rb
@@ -6,6 +6,15 @@ RSpec.describe "bundle exec" do
system_gems(system_gems_to_install, :path => :bundle_path)
end
+ it "works with --gemfile flag" do
+ create_file "CustomGemfile", <<-G
+ gem "rack", "1.0.0"
+ G
+
+ bundle "exec --gemfile CustomGemfile rackup"
+ expect(out).to eq("1.0.0")
+ end
+
it "activates the correct gem" do
gemfile <<-G
gem "rack", "0.9.1"