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 2.0.6 to 2.1.0

tests/fixtures/existing-manifest/input/assets/application.js

33

lib/fingerprint.js

@@ -7,2 +7,5 @@ var fs = require('fs');

var MANIFEST_REGEX = /^manifest(-[0-9a-f]+)?.json$/;
var MULTIPLE_MANIFEST_FILES = 'Multiple manifest files found. Using the first one.';
function Fingerprint(inputTree, options) {

@@ -101,8 +104,29 @@ if (!(this instanceof Fingerprint)) {

Fingerprint.prototype.findExistingManifest = function(destDir) {
var files = fs.readdirSync(destDir + '/assets');
var manifestFiles = files.filter(function(file) {
return MANIFEST_REGEX.test(file);
});
if(manifestFiles.length > 1) {
console.warn(MULTIPLE_MANIFEST_FILES);
}
return manifestFiles[0];
}
Fingerprint.prototype.writeRailsManifest = function(destDir) {
var assetRegex = /^assets\//,
digestRegex = /-([0-9a-f]+)\.\w+$/,
existingManifestPath = this.findExistingManifest(destDir),
fullExistingManifestPath = destDir + '/assets/' + existingManifestPath,
existingManifest = {},
assetMap = {},
files = {};
if(existingManifestPath){
existingManifest = JSON.parse(fs.readFileSync(fullExistingManifestPath));
assetMap = existingManifest.assets;
files = existingManifest.files;
}
for (var key in this.assetMap) {

@@ -124,5 +148,6 @@ if (assetRegex.test(key)) {

}
var assets = { assets: assetMap, files: files };
var fileName = 'manifest';
var assets = { assets: assetMap, files: files }
var contents = new Buffer(JSON.stringify(assets));
var fileName = 'manifest';

@@ -134,2 +159,6 @@ if (this.exclude.indexOf('manifest.json') === -1) {

if(existingManifestPath) {
fs.unlinkSync(fullExistingManifestPath);
}
fs.writeFileSync(destDir + '/assets/' + fileName + '.json', contents);

@@ -136,0 +165,0 @@ };

3

package.json
{
"name": "broccoli-asset-rev",
"version": "2.0.6",
"version": "2.1.0",
"description": "broccoli asset revisions (fingerprint)",

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

"mocha": "^2.0.1",
"sinon": "^1.14.1",
"walk-sync": "^0.1.3"
}
}

@@ -56,2 +56,3 @@ #broccoli-asset-rev

```
- `ignore` - Default: `[]` - An array of strings. If a filename contains any item in the ignore array, the contents of the file will not be processed for fingerprinting.

@@ -58,0 +59,0 @@ ## Ember CLI addon usage

@@ -8,5 +8,4 @@ var fs = require('fs');

var mergeTrees = require('broccoli-merge-trees');
var assetRev = require('../lib/asset-rev');
var assetRev = require('../lib/asset-rev');
var sinon = require('sinon');
var builder;

@@ -203,2 +202,53 @@

});
it('creates a sprockets-style manifest', function(){
var sourcePath = 'tests/fixtures/manifest';
var date = new Date(Date.UTC(2015, 0, 1, 8));
var original = fs.statSync;
sinon.stub(fs, 'statSync', function (path) {
var stats = original.apply(this, arguments);
stats.mtime = date;
return stats;
});
var tree = assetRev(sourcePath + '/input', {
extensions: ['js', 'css', 'png', 'jpg', 'gif', 'map'],
replaceExtensions: ['html', 'js', 'css'],
generateRailsManifest: true
});
builder = new broccoli.Builder(tree);
return builder.build().then(function(graph) {
confirmOutput(graph.directory, sourcePath + '/output');
fs.statSync.restore()
});
});
it('merges the generated manifest with the sprockets manifest', function(){
var sourcePath = 'tests/fixtures/existing-manifest';
var original = fs.statSync;
var date = new Date(Date.UTC(2015, 0, 1, 8));
sinon.stub(fs, 'statSync', function (path) {
var stats = original.apply(this, arguments);
stats.mtime = date;
return stats;
});
var tree = assetRev(sourcePath + '/input', {
extensions: ['js', 'css', 'png', 'jpg', 'gif', 'map'],
replaceExtensions: ['html', 'js', 'css'],
generateRailsManifest: true
});
builder = new broccoli.Builder(tree);
return builder.build().then(function(graph) {
confirmOutput(graph.directory, sourcePath + '/output');
fs.statSync.restore()
});
});
});
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