[rubygems/rubygems] Autoload shellwords when it's needed.

https://github.com/rubygems/rubygems/commit/e916ccb2d9
This commit is contained in:
Samuel Williams 2023-06-09 22:10:56 +09:00 коммит произвёл git
Родитель c74f42a4fb
Коммит 27b07776c9
4 изменённых файлов: 11 добавлений и 8 удалений

Просмотреть файл

@ -7,6 +7,7 @@
#++
require_relative "../user_interaction"
require_relative "../shellwords"
class Gem::Ext::Builder
include Gem::UserInteraction
@ -55,9 +56,8 @@ class Gem::Ext::Builder
end
def self.ruby
require "shellwords"
# Gem.ruby is quoted if it contains whitespace
cmd = Gem.ruby.shellsplit
cmd = Shellwords.split(Gem.ruby)
# This load_path is only needed when running rubygems test without a proper installation.
# Prepending it in a normal installation will cause problem with order of $LOAD_PATH.
@ -82,8 +82,7 @@ class Gem::Ext::Builder
p(command)
end
results << "current directory: #{dir}"
require "shellwords"
results << command.shelljoin
results << Shellwords.join(command)
require "open3"
# Set $SOURCE_DATE_EPOCH for the subprocess.

Просмотреть файл

@ -1,5 +1,7 @@
# frozen_string_literal: true
require_relative "../shellwords"
# This class is used by rubygems to build Rust extensions. It is a thin-wrapper
# over the `cargo rustc` command which takes care of building Rust code in a way
# that Ruby can use.
@ -73,8 +75,6 @@ class Gem::Ext::CargoBuilder < Gem::Ext::Builder
end
def cargo_command(cargo_toml, dest_path, args = [], crate_name = nil)
require "shellwords"
cmd = []
cmd += [cargo, "rustc"]
cmd += ["--crate-type", "cdylib"]

Просмотреть файл

@ -1,5 +1,7 @@
# frozen_string_literal: true
require_relative "../shellwords"
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
@ -15,8 +17,7 @@ class Gem::Ext::RakeBuilder < Gem::Ext::Builder
rake = ENV["rake"]
if rake
require "shellwords"
rake = rake.shellsplit
rake = Shellwords.split(rake)
else
begin
rake = ruby << "-rrubygems" << Gem.bin_path("rake", "rake")

Просмотреть файл

@ -0,0 +1,3 @@
# frozen_string_literal: true
autoload :Shellwords, "shellwords"