Skip to content

Commit

Permalink
cmd/*-sync: avoid clobbering existing user installations
Browse files Browse the repository at this point in the history
If a user already has an existing version installed, let's avoid
deleting it.
  • Loading branch information
carlocab committed Apr 26, 2024
1 parent f5cde8a commit dde493c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Library/Homebrew/cmd/nodenv-sync.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ def link_nodenv_versions(path, nodenv_versions)
(0..minor_version).each do |minor|
(0..patch_version).each do |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.ln_sf path, link_path
Expand Down
2 changes: 2 additions & 0 deletions Library/Homebrew/cmd/pyenv-sync.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ def link_pyenv_versions(path, pyenv_versions)

(0..patch_version).each do |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.ln_sf path, link_path
Expand Down
2 changes: 2 additions & 0 deletions Library/Homebrew/cmd/rbenv-sync.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ def link_rbenv_versions(path, rbenv_versions)

(0..patch_version).each do |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.ln_sf path, link_path
Expand Down

0 comments on commit dde493c

Please sign in to comment.