Apply suggestions from code review

These are just a few style improvements.

Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
This commit is contained in:
Carlo Cabrera 2021-10-27 18:25:59 +08:00
parent 96f0441178
commit 457de40117
No known key found for this signature in database
GPG Key ID: C74D447FC549A1D0
2 changed files with 9 additions and 7 deletions

View File

@ -172,8 +172,7 @@ class Keg
end end
relocation.add_replacement_pair(:perl, PERL_PLACEHOLDER, perl_path) relocation.add_replacement_pair(:perl, PERL_PLACEHOLDER, perl_path)
openjdk = openjdk_dep_name_if_applicable if (openjdk = openjdk_dep_name_if_applicable)
if openjdk
openjdk_path = HOMEBREW_PREFIX/"opt"/openjdk/"libexec/openjdk.jdk/Contents/Home" openjdk_path = HOMEBREW_PREFIX/"opt"/openjdk/"libexec/openjdk.jdk/Contents/Home"
relocation.add_replacement_pair(:java, JAVA_PLACEHOLDER, openjdk_path.to_s) relocation.add_replacement_pair(:java, JAVA_PLACEHOLDER, openjdk_path.to_s)
end end

View File

@ -116,8 +116,9 @@ class Keg
relocation.add_replacement_pair(:repository, REPOSITORY_PLACEHOLDER, HOMEBREW_REPOSITORY.to_s) relocation.add_replacement_pair(:repository, REPOSITORY_PLACEHOLDER, HOMEBREW_REPOSITORY.to_s)
relocation.add_replacement_pair(:library, LIBRARY_PLACEHOLDER, HOMEBREW_LIBRARY.to_s) relocation.add_replacement_pair(:library, LIBRARY_PLACEHOLDER, HOMEBREW_LIBRARY.to_s)
relocation.add_replacement_pair(:perl, PERL_PLACEHOLDER, "#{HOMEBREW_PREFIX}/opt/perl/bin/perl") relocation.add_replacement_pair(:perl, PERL_PLACEHOLDER, "#{HOMEBREW_PREFIX}/opt/perl/bin/perl")
openjdk = openjdk_dep_name_if_applicable if (openjdk = openjdk_dep_name_if_applicable)
relocation.add_replacement_pair(:java, JAVA_PLACEHOLDER, "#{HOMEBREW_PREFIX}/opt/#{openjdk}/libexec") if openjdk relocation.add_replacement_pair(:java, JAVA_PLACEHOLDER, "#{HOMEBREW_PREFIX}/opt/#{openjdk}/libexec")
end
relocation relocation
end end
@ -130,9 +131,11 @@ class Keg
end end
def openjdk_dep_name_if_applicable def openjdk_dep_name_if_applicable
runtime_dependencies&.find do |dep| deps = runtime_dependencies
dep["full_name"].match? Version.formula_optionally_versioned_regex(:openjdk) return if deps.blank?
end&.fetch("full_name")
dep_names = deps.map { |d| d["full_name"] }
dep_names.find { |d| d.match? Version.formula_optionally_versioned_regex(:openjdk) }
end end
def replace_text_in_files(relocation, files: nil) def replace_text_in_files(relocation, files: nil)