Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Commit

Permalink
Extract a gem_command method
Browse files Browse the repository at this point in the history
And use it consistently.
  • Loading branch information
deivid-rodriguez committed Dec 9, 2019
1 parent f5a2254 commit cddda67
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/bundler/gem_helper.rb
Expand Up @@ -73,8 +73,7 @@ def install

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")
Expand All @@ -85,8 +84,7 @@ def build_gem

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/]
Expand All @@ -98,7 +96,7 @@ def install_gem(built_gem_path = nil, local = false)
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?
Expand Down Expand Up @@ -211,5 +209,9 @@ def gem_key
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

0 comments on commit cddda67

Please sign in to comment.