lib/bundler/patch/cli.rb in bundler-patch-1.1.0.pre3 vs lib/bundler/patch/cli.rb in bundler-patch-1.1.0.pre4

- old
+ new

@@ -63,27 +63,32 @@ def patch(options={}) Bundler.ui = Bundler::UI::Shell.new options = Bundler::Patch::CLI::Options.new.normalize_options(options) - if options[:use_target_ruby] # TODO: && different_ruby_found - tb = options[:target] - ruby = tb.ruby_bin_exe - tb.install_bundler_patch_in_target - bundler_patch = File.join(tb.ruby_bin, 'bundler-patch') # uses 'latest' bundler-patch, which can work after we've installed ours. - full_command = "#{ruby} #{bundler_patch} #{options[:original_command].gsub(/use_target_ruby/, '')}" - result = shell_command(full_command) - puts result[:stdout] unless ENV['BP_DEBUG'] + tb = options[:target] + if options[:use_target_ruby] && tb.target_ruby_is_different? + launch_target_bundler_patch(options) else return list(options) if options[:list] patch_ruby(options) if options[:ruby] patch_gems(options) end end + def launch_target_bundler_patch(options) + tb = options[:target] + ruby = tb.ruby_bin_exe + tb.install_bundler_patch_in_target + bundler_patch = File.join(tb.ruby_bin, 'bundler-patch') + full_command = "#{ruby} #{bundler_patch} #{options[:original_command].gsub(/use_target_ruby/, '')}" + result = shell_command(full_command) + puts result[:stdout] unless ENV['BP_DEBUG'] + end + private def list(options) gem_patches = AdvisoryConsolidator.new(options).vulnerable_gems @@ -150,12 +155,12 @@ end end end def shell_command(command) + puts "-command: #{command}" if ENV['BP_DEBUG'] stdout, stderr, status = Open3.capture3(command) if ENV['BP_DEBUG'] - puts "-command: #{command}" puts "--stdout:#{indent(stdout)}" puts "--stderr:#{indent(stderr)}" end {stdout: stdout, stderr: stderr,