Sha256: 3fefec66316f1323e5874a63b5080b923c340380fddc03ba6f811b168523aafc
Contents?: true
Size: 909 Bytes
Versions: 1
Compression:
Stored size: 909 Bytes
Contents
# frozen_string_literal: true module Spandx module Js module Parsers class Npm < ::Spandx::Core::Parser def match?(filename) File.basename(filename) == 'package-lock.json' end def parse(path) items = Set.new each_metadata(path) do |metadata| items.add(map_from(path, metadata)) end items end private def each_metadata(file_path) package_lock = JSON.parse(IO.read(file_path)) package_lock['dependencies'].each do |name, metadata| yield metadata.merge('name' => name) end end def map_from(path, metadata) Spandx::Core::Dependency.new( path: path, name: metadata['name'], version: metadata['version'], meta: metadata ) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
spandx-0.13.4 | lib/spandx/js/parsers/npm.rb |