Class: Dependabot::NpmAndYarn::FileParser::YarnLockfileParser

Inherits:
Object
  • Object
show all
Defined in:
lib/dependabot/npm_and_yarn/file_parser/yarn_lockfile_parser.rb

Instance Method Summary collapse

Constructor Details

#initialize(lockfile:) ⇒ YarnLockfileParser

Returns a new instance of YarnLockfileParser.



10
11
12
# File 'lib/dependabot/npm_and_yarn/file_parser/yarn_lockfile_parser.rb', line 10

def initialize(lockfile:)
  @content = lockfile.content
end

Instance Method Details

#parseObject

This is extremely crude, but saves us from having to shell out to Yarn, which may not be safe



16
17
18
19
20
# File 'lib/dependabot/npm_and_yarn/file_parser/yarn_lockfile_parser.rb', line 16

def parse
  yaml = convert_to_yaml
  lockfile_object = parse_as_yaml(yaml)
  expand_lockfile_requirements(lockfile_object)
end