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



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

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



186
187
188
189
190
191
# File 'lib/dependabot/npm_and_yarn.rb', line 186

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



200
201
202
203
# File 'lib/dependabot/npm_and_yarn.rb', line 200

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