Sha256: 2c3d594e7ad6f8f8900bb078780f220ee5a5aedaaefa73980be65072e3caa2cd

Contents?: true

Size: 720 Bytes

Versions: 4

Compression:

Stored size: 720 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.values.each 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

4 entries across 4 versions & 1 rubygems

Version Path
cobra_commander-0.9.0 lib/cobra_commander/dependencies/yarn/package_repo.rb
cobra_commander-0.8.1 lib/cobra_commander/dependencies/yarn/package_repo.rb
cobra_commander-0.8.0 lib/cobra_commander/dependencies/yarn/package_repo.rb
cobra_commander-0.7.0 lib/cobra_commander/dependencies/yarn/package_repo.rb