Sha256: 60caadc2b097d4e030336f0a94b78f42143c48eab0538ab4d61c19db24e9008f

Contents?: true

Size: 718 Bytes

Versions: 7

Compression:

Stored size: 718 Bytes

Contents

# frozen_string_literal: true

module CobraCommander
  module Dependencies
    module Yarn
      # Yarn package repository to load and cache package.json files
      class PackageRepo
        def initialize
          @specs = {}
        end

        def specs
          @specs.values
        end

        def load_linked_specs(package)
          package.dependencies.each_value do |spec|
            next unless spec =~ /link:(.+)/

            load_spec(File.join(package.path, "..", Regexp.last_match(1)))
          end
        end

        def load_spec(path)
          @specs[path] ||= Package.new(path).tap do |package|
            load_linked_specs(package)
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
cobra_commander-0.14.0 lib/cobra_commander/dependencies/yarn/package_repo.rb
cobra_commander-0.13.0 lib/cobra_commander/dependencies/yarn/package_repo.rb
cobra_commander-0.12.0 lib/cobra_commander/dependencies/yarn/package_repo.rb
cobra_commander-0.11.0 lib/cobra_commander/dependencies/yarn/package_repo.rb
cobra_commander-0.10.0 lib/cobra_commander/dependencies/yarn/package_repo.rb
cobra_commander-0.9.2 lib/cobra_commander/dependencies/yarn/package_repo.rb
cobra_commander-0.9.1 lib/cobra_commander/dependencies/yarn/package_repo.rb