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



203
204
205
206
207
208
209
210
211
# File 'lib/dependabot/npm_and_yarn.rb', line 203

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



214
215
216
217
218
219
# File 'lib/dependabot/npm_and_yarn.rb', line 214

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



228
229
230
231
# File 'lib/dependabot/npm_and_yarn.rb', line 228

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