module Hrw module Scanner class PackageLock attr_reader :package_manager # Class constructor # # @param [String] root The path to the project root # @param [String] lockfile # The name for the lock file, default is `Pipfile.lock` def initialize(root = Dir.pwd, lockfile = 'package-lock.json') @package_manager = 'npm' @root = root @lockfile = lockfile end # Scan the lock file # @return [Hash] Dependencies def scan deps = [] obj = JSON.parse(File.read(File.join(@root, @lockfile))) obj['dependencies'].each_pair do |name, pkg| deps << { name: name, version: pkg['version'] } end deps end end end end