rbinstall.rb: fix the position to expand files

As `spec.files` is used for `executables` and so on, the expanded
list needs to be located at the same place.
This commit is contained in:
Nobuyoshi Nakada 2020-12-07 22:27:29 +09:00
Родитель c6b37cb169
Коммит 5894ea5954
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 7CD2805BFA3770C6
1 изменённых файлов: 13 добавлений и 13 удалений

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

@ -874,24 +874,24 @@ end
def load_gemspec(file, expanded = false) def load_gemspec(file, expanded = false)
file = File.realpath(file) file = File.realpath(file)
code = File.read(file, encoding: "utf-8:-") code = File.read(file, encoding: "utf-8:-")
code.gsub!(/`git.*?`/m, '""') code.gsub!(/(?:`git[^\`]*`|%x\[git[^\]]*\])\.split\(\"(?:\\.|[^\"])*\"\)/m) do
code.gsub!(/%x\[git.*?\]/m, '""') files = []
spec = eval(code, binding, file)
unless Gem::Specification === spec
raise TypeError, "[#{file}] isn't a Gem::Specification (#{spec.class} instead)."
end
spec.loaded_from = file
# gather expanded bundled gem files
if expanded if expanded
base = File.dirname(file) base = File.dirname(file)
Dir.glob("**/*", File::FNM_DOTMATCH, base: base) do |n| Dir.glob("**/*", File::FNM_DOTMATCH, base: base) do |n|
next if n.start_with?(".git") # git related files are useless next if n.start_with?(".git") # git related files are useless
case File.basename(n); when ".", ".."; next; end case File.basename(n); when ".", ".."; next; end
next if File.directory?(File.join(base, n)) next if File.directory?(File.join(base, n))
spec.files << n files << n.dump
end end
end end
"[" + files.join(", ") + "]"
end
spec = eval(code, binding, file)
unless Gem::Specification === spec
raise TypeError, "[#{file}] isn't a Gem::Specification (#{spec.class} instead)."
end
spec.loaded_from = file
spec spec
end end