Class: Homebrew::Cmd::NodenvSync Private
- Inherits:
-
AbstractCommand
- Object
- AbstractCommand
- Homebrew::Cmd::NodenvSync
- Defined in:
- cmd/nodenv-sync.rb,
sorbet/rbi/dsl/homebrew/cmd/nodenv_sync.rbi
This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.
Defined Under Namespace
Classes: Args
Instance Method Summary collapse
- #args ⇒ Homebrew::Cmd::NodenvSync::Args private
- #run ⇒ void private
Methods inherited from AbstractCommand
command, command_name, dev_cmd?, #initialize, parser, ruby_cmd?
Methods included from Utils::Output::Mixin
#issue_reporting_message, #odebug, #odeprecated, #odie, #odisabled, #ofail, #oh1, #oh1_title, #ohai, #ohai_title, #onoe, #opoo, #opoo_once, #opoo_outside_github_actions, #opoo_without_github_actions_annotation, #pretty_cannot_install, #pretty_deprecated, #pretty_disabled, #pretty_duration, #pretty_incompatible, #pretty_install_status, #pretty_installed, #pretty_removed, #pretty_uninstalled, #pretty_unmarked, #pretty_upgradable, #pretty_warning
Constructor Details
This class inherits a constructor from Homebrew::AbstractCommand
Instance Method Details
#args ⇒ Homebrew::Cmd::NodenvSync::Args
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
10 |
# File 'sorbet/rbi/dsl/homebrew/cmd/nodenv_sync.rbi', line 10 def args; end |
#run ⇒ void
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
This method returns an undefined value.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'cmd/nodenv-sync.rb', line 23 def run nodenv_root = Pathname(ENV.fetch("HOMEBREW_NODENV_ROOT", Pathname(Dir.home)/".nodenv")) # Don't run multiple times at once. nodenv_sync_running = nodenv_root/".nodenv_sync_running" return if nodenv_sync_running.exist? begin nodenv_versions = nodenv_root/"versions" nodenv_versions.mkpath FileUtils.touch nodenv_sync_running HOMEBREW_CELLAR.glob("node{,@*}") .flat_map(&:children) .each do |path| version = Keg.new(path).version major_version = version.major.to_i minor_version = version.minor.to_i patch_version = version.patch.to_i minor_version_range, patch_version_range = if Homebrew::EnvConfig.env_sync_strict? # Only create symlinks for the exact installed patch version. # e.g. 23.9.0 => 23.9.0 [[minor_version], [patch_version]] else # Create folder symlinks for all patch versions to the latest patch version # e.g. 23.9.0 => 23.10.1 [0..minor_version, 0..patch_version] end minor_version_range.each do |minor| patch_version_range.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_s path, link_path end end end 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 |