Fix single process logic in rbenv-sync and nodenv-sync

This commit is contained in:
John Britton 2023-06-29 09:54:18 -04:00
parent 03b455f460
commit 24c014b506
No known key found for this signature in database
GPG Key ID: 0EDB5B1148D612F2
2 changed files with 30 additions and 26 deletions

View File

@ -29,22 +29,24 @@ module Homebrew
nodenv_sync_running = dot_nodenv/".nodenv_sync_running"
return if nodenv_sync_running.exist?
nodenv_versions = dot_nodenv/"versions"
nodenv_versions.mkpath
FileUtils.touch nodenv_sync_running
begin
nodenv_versions = dot_nodenv/"versions"
nodenv_versions.mkpath
FileUtils.touch nodenv_sync_running
nodenv_sync_args.parse
nodenv_sync_args.parse
HOMEBREW_CELLAR.glob("node{,@*}")
.flat_map(&:children)
.each { |path| link_nodenv_versions(path, nodenv_versions) }
HOMEBREW_CELLAR.glob("node{,@*}")
.flat_map(&:children)
.each { |path| link_nodenv_versions(path, nodenv_versions) }
nodenv_versions.children
.select(&:symlink?)
.reject(&:exist?)
.each { |path| FileUtils.rm_f path }
ensure
nodenv_sync_running.unlink if nodenv_sync_running.exist?
nodenv_versions.children
.select(&:symlink?)
.reject(&:exist?)
.each { |path| FileUtils.rm_f path }
ensure
nodenv_sync_running.unlink if nodenv_sync_running.exist?
end
end
sig { params(path: Pathname, nodenv_versions: Pathname).void }

View File

@ -29,22 +29,24 @@ module Homebrew
rbenv_sync_running = dot_rbenv/".rbenv_sync_running"
return if rbenv_sync_running.exist?
rbenv_versions = dot_rbenv/"versions"
rbenv_versions.mkpath
FileUtils.touch rbenv_sync_running
begin
rbenv_versions = dot_rbenv/"versions"
rbenv_versions.mkpath
FileUtils.touch rbenv_sync_running
rbenv_sync_args.parse
rbenv_sync_args.parse
HOMEBREW_CELLAR.glob("ruby{,@*}")
.flat_map(&:children)
.each { |path| link_rbenv_versions(path, rbenv_versions) }
HOMEBREW_CELLAR.glob("ruby{,@*}")
.flat_map(&:children)
.each { |path| link_rbenv_versions(path, rbenv_versions) }
rbenv_versions.children
.select(&:symlink?)
.reject(&:exist?)
.each { |path| FileUtils.rm_f path }
ensure
rbenv_sync_running.unlink if rbenv_sync_running.exist?
rbenv_versions.children
.select(&:symlink?)
.reject(&:exist?)
.each { |path| FileUtils.rm_f path }
ensure
rbenv_sync_running.unlink if rbenv_sync_running.exist?
end
end
sig { params(path: Pathname, rbenv_versions: Pathname).void }