Sha256: 50d1f09756a1b291cca48df1de39272e19d8feb4f19540137f42bbcd1c668461
Contents?: true
Size: 722 Bytes
Versions: 5
Compression:
Stored size: 722 Bytes
Contents
# frozen_string_literal: true require "json" require "pathname" module CobraCommander module Dependencies module Yarn # Represents an Yarn package.json file class Package attr_reader :path def initialize(path) @path = ::Pathname.new(File.join(path, "package.json")).realpath end def project_tag name.match(%r{^@[\w-]+/}).to_s end def name json["name"] end def dependencies json.fetch("dependencies", {}) .merge(json.fetch("devDependencies", {})) end private def json @json ||= JSON.parse(File.read(@path)) end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems