Module: Dependabot::NpmAndYarn::Helpers

Defined in:
lib/dependabot/npm_and_yarn/helpers.rb

Class Method Summary collapse

Class Method Details

.npm_version(lockfile_content) ⇒ Object



6
7
8
# File 'lib/dependabot/npm_and_yarn/helpers.rb', line 6

def self.npm_version(lockfile_content)
  "npm#{npm_version_numeric(lockfile_content)}"
end

.npm_version_numeric(lockfile_content) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/dependabot/npm_and_yarn/helpers.rb', line 10

def self.npm_version_numeric(lockfile_content)
  return 8 unless lockfile_content
  return 8 if JSON.parse(lockfile_content)["lockfileVersion"] >= 2

  6
rescue JSON::ParserError
  6
end