keg: check that alias path exists before checking realpath.

Otherwise this can be a broken symlink which will raise an exception:
https://github.com/Homebrew/homebrew-core/runs/1704569542?check_suite_focus=true#step:6:47
This commit is contained in:
Mike McQuaid 2021-01-15 08:57:02 +00:00
parent 053ca17b50
commit 1857dfcd2e
No known key found for this signature in database
GPG Key ID: 48A898132FD8EE70

View File

@ -650,7 +650,7 @@ class Keg
def remove_alias_symlink(alias_symlink, alias_match_path)
if alias_symlink.symlink? && alias_symlink.exist?
alias_symlink.delete if alias_symlink.realpath == alias_match_path.realpath
alias_symlink.delete if alias_match_path.exist? && alias_symlink.realpath == alias_match_path.realpath
elsif alias_symlink.symlink? || alias_symlink.exist?
alias_symlink.delete
end