diff options
author | ankitkataria <ankitkataria28@gmail.com> | 2018-08-24 18:33:48 +0530 |
---|---|---|
committer | ankitkataria <ankitkataria28@gmail.com> | 2018-08-24 18:33:48 +0530 |
commit | 0f8dd3e0ef53203cd09151e45c57330a948dd571 (patch) | |
tree | 26ba8def3ddc026bac2487886a58eae715a5c366 | |
parent | 72f27b0dd8c92159bf769a531cfa97672bf4c1e4 (diff) | |
download | bundler-0f8dd3e0ef53203cd09151e45c57330a948dd571.tar.gz |
Add gemfile flag to exec command
-rw-r--r-- | lib/bundler/cli.rb | 1 | ||||
-rw-r--r-- | lib/bundler/cli/exec.rb | 4 | ||||
-rw-r--r-- | lib/bundler/shared_helpers.rb | 5 |
3 files changed, 10 insertions, 0 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index f1ff3f4554..f692ae5f13 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -437,6 +437,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/lib/bundler/cli/exec.rb b/lib/bundler/cli/exec.rb index 386565c575..252a0d2b1f 100644 --- a/lib/bundler/cli/exec.rb +++ b/lib/bundler/cli/exec.rb @@ -23,6 +23,10 @@ module Bundler def run validate_cmd! SharedHelpers.set_bundle_environment + + # setting the gemfile if mentioned + SharedHelpers.custom_gemfile(@options[:gemfile]) unless @options[:gemfile].nil? + if bin_path = Bundler.which(cmd) if !Bundler.settings[:disable_exec_load] && ruby_shebang?(bin_path) return kernel_load(bin_path, *args) diff --git a/lib/bundler/shared_helpers.rb b/lib/bundler/shared_helpers.rb index 7ff391ab60..b3051b9f2e 100644 --- a/lib/bundler/shared_helpers.rb +++ b/lib/bundler/shared_helpers.rb @@ -230,6 +230,11 @@ module Bundler filesystem_access(gemfile_path) {|g| File.open(g, "w") {|file| file.puts contents } } end + def custom_gemfile(gemfile) + file = find_file(gemfile).to_s + Bundler::SharedHelpers.set_env "BUNDLE_GEMFILE", file unless file.nil? + end + private def validate_bundle_path |