summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2020-12-07 22:27:29 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2020-12-07 22:38:09 +0900
commit5894ea5954db119fc818bb7030ed56cf46830c6d (patch)
treeb5f7aa4eced0842a8d1398a8bebf290643bfd848
parentc6b37cb169f190bac46c76a643350ee4ffc3dfca (diff)
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.
-rwxr-xr-xtool/rbinstall.rb26
1 files changed, 13 insertions, 13 deletions
diff --git a/tool/rbinstall.rb b/tool/rbinstall.rb
index 97cde087c6..fcc41f2151 100755
--- a/tool/rbinstall.rb
+++ b/tool/rbinstall.rb
@@ -874,25 +874,25 @@ end
def load_gemspec(file, expanded = false)
file = File.realpath(file)
code = File.read(file, encoding: "utf-8:-")
- code.gsub!(/`git.*?`/m, '""')
- code.gsub!(/%x\[git.*?\]/m, '""')
+ code.gsub!(/(?:`git[^\`]*`|%x\[git[^\]]*\])\.split\(\"(?:\\.|[^\"])*\"\)/m) do
+ files = []
+ if expanded
+ base = File.dirname(file)
+ Dir.glob("**/*", File::FNM_DOTMATCH, base: base) do |n|
+ next if n.start_with?(".git") # git related files are useless
+ case File.basename(n); when ".", ".."; next; end
+ next if File.directory?(File.join(base, n))
+ files << n.dump
+ 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
- # gather expanded bundled gem files
- if expanded
- base = File.dirname(file)
- Dir.glob("**/*", File::FNM_DOTMATCH, base: base) do |n|
- next if n.start_with?(".git") # git related files are useless
- case File.basename(n); when ".", ".."; next; end
- next if File.directory?(File.join(base, n))
- spec.files << n
- end
- end
-
spec
end