diff options
author | David RodrÃguez <deivid.rodriguez@riseup.net> | 2019-12-09 18:04:32 +0100 |
---|---|---|
committer | David RodrÃguez <deivid.rodriguez@riseup.net> | 2019-12-09 18:04:32 +0100 |
commit | cddda67520e3618cd5a5577a62a5dab4bfa5f9c5 (patch) | |
tree | 143d37bb94d80429910e678d2893a1189855105c /lib | |
parent | f5a225499d16c8185105251ea4f8e924dd5d55e7 (diff) | |
download | bundler-cddda67520e3618cd5a5577a62a5dab4bfa5f9c5.tar.gz |
Extract a `gem_command` method
And use it consistently.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/bundler/gem_helper.rb | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/bundler/gem_helper.rb b/lib/bundler/gem_helper.rb index e1eb044553..b510572cb8 100644 --- a/lib/bundler/gem_helper.rb +++ b/lib/bundler/gem_helper.rb @@ -73,8 +73,7 @@ module Bundler def build_gem file_name = nil - gem = ENV["GEM_COMMAND"] ? ENV["GEM_COMMAND"] : "gem" - sh("#{gem} build -V #{spec_path}".shellsplit) do + sh("#{gem_command} build -V #{spec_path}".shellsplit) do file_name = File.basename(built_gem_path) SharedHelpers.filesystem_access(File.join(base, "pkg")) {|p| FileUtils.mkdir_p(p) } FileUtils.mv(built_gem_path, "pkg") @@ -85,8 +84,7 @@ module Bundler def install_gem(built_gem_path = nil, local = false) built_gem_path ||= build_gem - gem = ENV["GEM_COMMAND"] ? ENV["GEM_COMMAND"] : "gem" - cmd = "#{gem} install #{built_gem_path}" + cmd = "#{gem_command} install #{built_gem_path}" cmd += " --local" if local out, status = sh_with_status(cmd.shellsplit) unless status.success? && out[/Successfully installed/] @@ -98,7 +96,7 @@ module Bundler protected def rubygem_push(path) - cmd = %W[gem push #{path}] + cmd = %W[#{gem_command} push #{path}] cmd << "--key" << gem_key if gem_key cmd << "--host" << allowed_push_host if allowed_push_host unless allowed_push_host || Bundler.user_home.join(".gem/credentials").file? @@ -211,5 +209,9 @@ module Bundler def gem_push? !%w[n no nil false off 0].include?(ENV["gem_push"].to_s.downcase) end + + def gem_command + ENV["GEM_COMMAND"] ? ENV["GEM_COMMAND"] : "gem" + end end end |