Class: Homebrew::Cmd::NodenvSync Private

Inherits:
AbstractCommand show all
Defined in:
sorbet/rbi/dsl/homebrew/cmd/nodenv_sync.rbi,
cmd/nodenv-sync.rb

Overview

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.

DO NOT EDIT MANUALLY This is an autogenerated file for dynamic methods in Homebrew::Cmd::NodenvSync. Please instead update this file by running bin/tapioca dsl Homebrew::Cmd::NodenvSync.

Defined Under Namespace

Classes: Args

Instance Method Summary collapse

Methods inherited from AbstractCommand

command, command_name, dev_cmd?, #initialize, parser

Constructor Details

This class inherits a constructor from Homebrew::AbstractCommand

Instance Method Details

#argsHomebrew::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.



9
# File 'sorbet/rbi/dsl/homebrew/cmd/nodenv_sync.rbi', line 9

def args; end

#runvoid

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.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'cmd/nodenv-sync.rb', line 22

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 { |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?
  end
end