cmd/*-sync: avoid clobbering existing user installations

If a user already has an existing version installed, let's avoid
deleting it.
This commit is contained in:
Carlo Cabrera 2024-04-26 18:32:54 +08:00
parent f5cde8ad0d
commit dde493c6e9
No known key found for this signature in database
GPG Key ID: C74D447FC549A1D0
3 changed files with 6 additions and 0 deletions

View File

@ -58,6 +58,8 @@ module Homebrew
(0..minor_version).each do |minor| (0..minor_version).each do |minor|
(0..patch_version).each do |patch| (0..patch_version).each do |patch|
link_path = nodenv_versions/"#{major_version}.#{minor}.#{patch}" link_path = nodenv_versions/"#{major_version}.#{minor}.#{patch}"
# Don't clobber existing user installations.
next if link_path.exist? && !link_path.symlink?
FileUtils.rm_f link_path FileUtils.rm_f link_path
FileUtils.ln_sf path, link_path FileUtils.ln_sf path, link_path

View File

@ -56,6 +56,8 @@ module Homebrew
(0..patch_version).each do |patch| (0..patch_version).each do |patch|
link_path = pyenv_versions/"#{major_version}.#{minor_version}.#{patch}" link_path = pyenv_versions/"#{major_version}.#{minor_version}.#{patch}"
# Don't clobber existing user installations.
next if link_path.exist? && !link_path.symlink?
FileUtils.rm_f link_path FileUtils.rm_f link_path
FileUtils.ln_sf path, link_path FileUtils.ln_sf path, link_path

View File

@ -57,6 +57,8 @@ module Homebrew
(0..patch_version).each do |patch| (0..patch_version).each do |patch|
link_path = rbenv_versions/"#{major_version}.#{minor_version}.#{patch}" link_path = rbenv_versions/"#{major_version}.#{minor_version}.#{patch}"
# Don't clobber existing user installations.
next if link_path.exist? && !link_path.symlink?
FileUtils.rm_f link_path FileUtils.rm_f link_path
FileUtils.ln_sf path, link_path FileUtils.ln_sf path, link_path