Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

broccoli-asset-rewrite

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

broccoli-asset-rewrite - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

tests/fixtures/extensions/input/styles.css

28

index.js

@@ -19,2 +19,4 @@ var Filter = require('broccoli-filter');

this.ignore = options.ignore || []; // files to ignore
this.assetMapKeys = null;
}

@@ -38,2 +40,6 @@

AssetRewrite.prototype.canProcessFile = function(relativePath) {
if (!this.assetMapKeys) {
this.generateAssetMapKeys();
}
if (!this.inverseAssetMap) {

@@ -105,3 +111,5 @@ var inverseAssetMap = {};

for (var key in this.assetMap) {
for (var i = 0, keyLength = this.assetMapKeys.length; i < keyLength; i++) {
var key = this.assetMapKeys[i];
if (this.assetMap.hasOwnProperty(key)) {

@@ -132,2 +140,20 @@ /*

AssetRewrite.prototype.generateAssetMapKeys = function () {
var keys = Object.keys(this.assetMap);
keys.sort(function (a, b) {
if (a.length < b.length) {
return 1;
}
if (a.length > b.length) {
return -1;
}
return 0;
});
this.assetMapKeys = keys;
}
function escapeRegExp(string) {

@@ -134,0 +160,0 @@ return string.replace(/([.*+?^${}()|\[\]\/\\])/g, "\\$1");

2

package.json
{
"name": "broccoli-asset-rewrite",
"version": "1.0.0",
"version": "1.0.1",
"description": "broccoli plugin to rewrite a source tree from an asset map.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -106,2 +106,21 @@ var fs = require('fs');

});
it('replaces the correct match for the file extension', function () {
var sourcePath = 'tests/fixtures/extensions';
var tree = rewrite(sourcePath + '/input', {
assetMap: {
'fonts/roboto-regular.eot': 'fonts/roboto-regular-f1.eot',
'fonts/roboto-regular.woff': 'fonts/roboto-regular-f3.woff',
'fonts/roboto-regular.ttf': 'fonts/roboto-regular-f4.ttf',
'fonts/roboto-regular.svg': 'fonts/roboto-regular-f5.svg',
'fonts/roboto-regular.woff2': 'fonts/roboto-regular-f2.woff2'
}
});
builder = new broccoli.Builder(tree);
return builder.build().then(function (graph) {
confirmOutput(graph.directory, sourcePath + '/output');
});
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc