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

View File

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