lib/licensed/sources/yarn/berry.rb in licensed-3.4.1 vs lib/licensed/sources/yarn/berry.rb in licensed-3.4.2

- old
+ new

@@ -30,11 +30,11 @@ # parse all lines of output to json and find one that is "type": "tree" yarn_info = JSON.parse("[#{yarn_info_command.lines.join(",")}]") mapped_packages = yarn_info.reduce({}) do |accum, package| name, _ = package["value"].rpartition("@") version = package.dig("children", "Version") - id = "#{name}-#{version}" + id = "#{name}@#{version}" accum[name] ||= [] accum[name] << { "id" => id, "name" => name, @@ -53,25 +53,9 @@ else # if there is more than one package for a name, reference each by id results.each do |package| hsh[package["id"]] = package end - end - end - end - - # Returns a hash that maps all dependency names to their location on disk - # by parsing every package.json file under node_modules. - def dependency_paths - @dependency_paths ||= Dir.glob(config.pwd.join("node_modules/**/package.json")).each_with_object({}) do |file, hsh| - begin - dirname = File.dirname(file) - json = JSON.parse(File.read(file)) - hsh["#{json["name"]}-#{json["version"]}"] = dirname - rescue JSON::ParserError - # don't crash execution if there is a problem parsing a package.json file - # if the bad package.json file relates to a package that licensed should be reporting on - # then this will still result in an error about a missing package end end end # Returns the output from running `yarn list` to get project dependencies