Module: Homebrew::Bundle::VscodeExtensionInstaller Private

Defined in:
bundle/vscode_extension_installer.rb

This module is part of a private API. This module may only be used in the Homebrew/brew repository. Third parties should avoid using this module if possible, as it may be removed or changed without warning.

Class Method Summary collapse

Class Method Details

.extension_installed?(name) ⇒ Boolean

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.

Parameters:

Returns:

  • (Boolean)


54
55
56
# File 'bundle/vscode_extension_installer.rb', line 54

def self.extension_installed?(name)
  installed_extensions.include? name.downcase
end

.install!(name, preinstall: true, no_upgrade: false, verbose: false, force: false) ⇒ Boolean

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.

Parameters:

  • name (String)
  • preinstall (Boolean) (defaults to: true)
  • no_upgrade (Boolean) (defaults to: false)
  • verbose (Boolean) (defaults to: false)
  • force (Boolean) (defaults to: false)

Returns:

  • (Boolean)


38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'bundle/vscode_extension_installer.rb', line 38

def self.install!(name, preinstall: true, no_upgrade: false, verbose: false, force: false)
  return true unless preinstall
  return true if extension_installed?(name)

  puts "Installing #{name} VSCode extension. It is not currently installed." if verbose

  return false unless Bundle.exchange_uid_if_needed! do
    Bundle.system(T.must(Bundle.which_vscode), "--install-extension", name, verbose:)
  end

  installed_extensions << name

  true
end

.installed_extensionsArray<String>

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.

Returns:



59
60
61
62
63
64
65
# File 'bundle/vscode_extension_installer.rb', line 59

def self.installed_extensions
  require "bundle/vscode_extension_dumper"
  @installed_extensions ||= T.let(
    Homebrew::Bundle::VscodeExtensionDumper.extensions,
    T.nilable(T::Array[String]),
  )
end

.preinstall!(name, no_upgrade: false, verbose: false) ⇒ Boolean

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.

Parameters:

  • name (String)
  • no_upgrade (Boolean) (defaults to: false)
  • verbose (Boolean) (defaults to: false)

Returns:

  • (Boolean)


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'bundle/vscode_extension_installer.rb', line 13

def self.preinstall!(name, no_upgrade: false, verbose: false)
  if !Bundle.vscode_installed? && Bundle.cask_installed?
    puts "Installing visual-studio-code. It is not currently installed." if verbose
    Bundle.brew("install", "--cask", "visual-studio-code", verbose:)
  end

  if extension_installed?(name)
    puts "Skipping install of #{name} VSCode extension. It is already installed." if verbose
    return false
  end

  raise "Unable to install #{name} VSCode extension. VSCode is not installed." unless Bundle.vscode_installed?

  true
end

.reset!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.



8
9
10
# File 'bundle/vscode_extension_installer.rb', line 8

def self.reset!
  @installed_extensions = nil
end