Class: Dependabot::NpmAndYarn::Utils

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/dependabot/npm_and_yarn.rb

Class Method Summary collapse

Class Method Details

.extract_node_versions(error_message) ⇒ Object



167
168
169
170
171
172
173
174
175
# File 'lib/dependabot/npm_and_yarn.rb', line 167

def self.extract_node_versions(error_message)
  match_data = error_message.match(NODE_VERSION_NOT_SATISFY_REGEX)
  return {} unless match_data

  {
    current_version: match_data[:current_version],
    required_version: match_data[:required_version]
  }
end

.extract_var(error_message) ⇒ Object



178
179
180
181
182
183
# File 'lib/dependabot/npm_and_yarn.rb', line 178

def self.extract_var(error_message)
  match_data = T.must(error_message.match(ENV_VAR_NOT_RESOLVABLE)).named_captures["var"]
  return "" unless match_data

  match_data
end

.sanitize_resolvability_message(error_message, dependencies, yarn_lock) ⇒ Object



192
193
194
195
# File 'lib/dependabot/npm_and_yarn.rb', line 192

def self.sanitize_resolvability_message(error_message, dependencies, yarn_lock)
  dependency_names = dependencies.map(&:name).join(", ")
  "Error whilst updating #{dependency_names} in #{yarn_lock.path}:\n#{error_message}"
end