Sha256: aae4bd9ae229f3778251455c99d8fd16ba9175f1b1a3ba84720244d83d231ab1
Contents?: true
Size: 1.22 KB
Versions: 1
Compression:
Stored size: 1.22 KB
Contents
require "ember_cli/errors" module EmberCli class AssetMap def initialize(ember_app_name:, asset_map:) @ember_app_name = ember_app_name @asset_map = asset_map end def javascripts assert_asset_map! [ asset_matching(%r{vendor(.*)\.js\z}), asset_matching(%r{#{ember_app_name}(.*)\.js\z}), ] end def stylesheets assert_asset_map! [ asset_matching(%r{vendor(.*)\.css\z}), asset_matching(%r{#{ember_app_name}(.*)\.css\z}), ] end private attr_reader :app_name, :ember_app_name, :asset_map def asset_matching(regex) matching_asset = files.detect { |asset| asset =~ regex } if matching_asset.blank? raise_missing_asset(regex) end prepend + matching_asset end def prepend asset_map["prepend"].to_s end def files Array(assets.values) end def assets asset_map["assets"] || {} end def raise_missing_asset(regex) raise BuildError.new("Failed to find assets matching `#{regex}`") end def assert_asset_map! if assets.empty? raise BuildError.new("Missing `#{ember_app_name}/assets/assetMap.json`") end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ember-cli-rails-0.6.0 | lib/ember_cli/asset_map.rb |