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-10-05 16:15:43 +1000
commit1e60abf649ddc343a21c62c243047f5eb2cd5a59 (patch)
tree04d9c1085749f31c1c6ae7deb183a01be01dfd62
parent328b1bdc747ee67f0b4888d2fcfb9f512e1d1924 (diff)
downloadbundler-1e60abf649ddc343a21c62c243047f5eb2cd5a59.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 19d605f971..706c0b90dc 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"