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

broccoli-asset-rev

Package Overview
Dependencies
Maintainers
1
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

broccoli-asset-rev - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

tests/fixtures/customHash-function/input/assets/application.js

26

lib/fingerprint.js

@@ -16,3 +16,2 @@ var fs = require('fs');

this.assetMap = options.assetMap || {};
this.customHash = options.customHash;
this.extensions = options.extensions || [];

@@ -24,2 +23,10 @@ this.exclude = options.exclude || [];

this.prepend = options.prepend;
if (typeof options.customHash === 'function') {
this.customHash = null;
this.hashFn = options.customHash;
} else {
this.customHash = options.customHash;
this.hashFn = md5Hash;
}
}

@@ -65,5 +72,3 @@

} else {
var md5 = crypto.createHash('md5');
md5.update(file);
hash = md5.digest('hex');
hash = this.hashFn(file);
}

@@ -117,7 +122,4 @@

var assets = { assets: assetMap, files: files };
var contents = JSON.stringify(assets);
var hash = '';
var md5 = crypto.createHash('md5');
md5.update(contents);
hash = md5.digest('hex');
var contents = new Buffer(JSON.stringify(assets));
var hash = this.hashFn(contents);
fs.writeFileSync(destDir + '/assets/manifest-' + hash + '.json', contents);

@@ -140,2 +142,8 @@ };

function md5Hash(buf) {
var md5 = crypto.createHash('md5');
md5.update(buf);
return md5.digest('hex');
}
module.exports = Fingerprint;
{
"name": "broccoli-asset-rev",
"version": "1.0.1",
"version": "1.1.0",
"description": "broccoli asset revisions (fingerprint)",

@@ -5,0 +5,0 @@ "main": "lib/asset-rev.js",

@@ -45,3 +45,3 @@ #broccoli-asset-rev

- `generateRailsManifest` - Default: none - If true, will generate a `manifest.json` to be used by Sprockets for the Rails Asset Pipeline
- `customHash` - Default: none - If defined, will be appended to filename instead of a md5 checksum.
- `customHash` - Default: none - If set, overrides the md5 checksum calculation with the result of calling `customHash(buffer)`. If it is not a `function`, `customHash` is used as the hash value.

@@ -48,0 +48,0 @@ ## Ember CLI addon usage

var fs = require('fs');
var path = require('path');
var crypto = require('crypto');
var assert = require('assert');

@@ -79,2 +80,36 @@ var walkSync = require('walk-sync');

});
it('uses customHash string value', function(){
var sourcePath = 'tests/fixtures/customHash-simple';
var tree = assetRev(sourcePath + '/input', {
extensions: ['js', 'css', 'png', 'jpg', 'gif'],
replaceExtensions: ['html', 'js', 'css'],
customHash: 'test'
});
builder = new broccoli.Builder(tree);
return builder.build().then(function(graph) {
confirmOutput(graph.directory, sourcePath + '/output');
});
});
it('uses customHash function value', function(){
var sourcePath = 'tests/fixtures/customHash-function';
var tree = assetRev(sourcePath + '/input', {
extensions: ['js', 'css', 'png', 'jpg', 'gif'],
replaceExtensions: ['html', 'js', 'css'],
customHash: function(buf) {
var sha1 = crypto.createHash('sha1');
sha1.update(buf);
return sha1.digest('hex');
}
});
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