Sha256: ea7ccd8c89e963aef76776ecaca55d2677c5cd3ef2c7e62103f3c457f8cb5ee7

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

class BowerVendor::Yarn < BowerVendor::Copy
  def full_vendor_src_dir(vendor)
    "node_modules/#{vendor}"
  end

  def accept_vendor?(vendor, vendor_data)
    vendor_data['yarn']
  end

  def load_vendors
    versions = load_vendor_versions

    vendors_data = YAML.load_file 'vendor.yml'
    vendors_data.delete_if { |vendor, vendor_data| !accept_vendor?(vendor, vendor_data) }

    vendors_data.each do |vendor, vendor_data|
      version = versions[vendor]
      raise "YARN: missing vendor: #{vendor}" unless version
      vendor_data['version'] = version
    end

    vendors_data
  end

  def load_vendor_versions
    data = File.read 'yarn.lock'
    lines = data.split("\n")

    versions = {}

    vendor = nil
    lines.each do |line|
      next if line.start_with?('#')
      if line.start_with?('  version')
        version = line.split(' ').last.tr('"', '')
        versions[vendor] = version
        vendor = nil
      elsif line.start_with?(' ')
        next
      else
        vendor = line.tr('"', '').split('@').first
      end
    end

    versions
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bower_vendor-0.1.3 lib/bower_vendor/yarn.rb