Class: Homebrew::Bundle::Npm Private
- Inherits:
-
Extension
- Object
- PackageType
- Extension
- Homebrew::Bundle::Npm
- Defined in:
- bundle/extensions/npm.rb
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.
Constant Summary collapse
- PACKAGE_TYPE =
This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.
:npm- PACKAGE_TYPE_NAME =
This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.
"npm Package"- BANNER_NAME =
This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.
"npm packages"
Class Method Summary collapse
- .install_package!(name, with: nil, verbose: false) ⇒ Boolean private
- .installed_packages ⇒ Array<String> private
- .package_manager_executable ⇒ Pathname? private
- .package_manager_name ⇒ String private
- .packages ⇒ Array<String> private
- .parse_package_list(output) ⇒ Array<String> private
- .reset! ⇒ void private
Methods inherited from Extension
add_supported?, banner_name, check, check_label, cleanup!, cleanup_heading, cleanup_items, cleanup_supported?, dump, dump_disable_description, dump_disable_env, dump_disable_predicate_method, dump_disable_supported?, dump_entry, dump_name, dump_output, dump_supported?, dump_with, entry, #failure_reason, fetchable_name, flag, inherited, install!, install_supported?, install_verb, #installed_and_up_to_date?, legacy_check_step, package_description, package_installed?, package_manager_installed?, package_record, predicate_method, preinstall!, quote, remove_supported?, switch_description, type
Methods inherited from PackageType
check, #checkable_entries, dump, dump_output, dump_supported?, #exit_early_check, #failure_reason, fetchable_name, #find_actionable, #format_checkable, #full_check, inherited, install!, install_supported?, install_verb, #installed_and_up_to_date?, preinstall!, type
Class Method Details
.install_package!(name, with: nil, 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.
51 52 53 54 55 56 57 58 |
# File 'bundle/extensions/npm.rb', line 51 def install_package!(name, with: nil, verbose: false) _ = with npm = package_manager_executable return false if npm.nil? Bundle.system(npm.to_s, "install", "-g", name, verbose:) end |
.installed_packages ⇒ Array<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.
61 62 63 64 65 66 |
# File 'bundle/extensions/npm.rb', line 61 def installed_packages installed_packages = @installed_packages return installed_packages if installed_packages @installed_packages = packages.dup end |
.package_manager_executable ⇒ Pathname?
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.
26 27 28 |
# File 'bundle/extensions/npm.rb', line 26 def package_manager_executable which("npm", ORIGINAL_PATHS) end |
.package_manager_name ⇒ 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.
21 22 23 |
# File 'bundle/extensions/npm.rb', line 21 def package_manager_name "node" end |
.packages ⇒ Array<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.
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'bundle/extensions/npm.rb', line 31 def packages packages = @packages return packages if packages @packages = if (npm = package_manager_executable) && (!npm.to_s.start_with?("/") || npm.exist?) parse_package_list(`#{npm} list -g --depth=0 --json 2>/dev/null`) end return [] if @packages.nil? @packages end |
.parse_package_list(output) ⇒ Array<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.
69 70 71 72 73 74 75 76 77 |
# File 'bundle/extensions/npm.rb', line 69 def parse_package_list(output) return [] if output.blank? json = JSON.parse(output) deps = json.fetch("dependencies", {}) deps.keys.reject { |name| name == "npm" } rescue JSON::ParserError [] 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.
15 16 17 18 |
# File 'bundle/extensions/npm.rb', line 15 def reset! @packages = T.let(nil, T.nilable(T::Array[String])) @installed_packages = T.let(nil, T.nilable(T::Array[String])) end |