broccoli-asset-rev
Advanced tools
Comparing version 0.0.6 to 0.0.7
@@ -23,2 +23,3 @@ var Fingerprint = require('./fingerprint'); | ||
exclude: options.fingerprintExclude || [], | ||
generateRailsManifest: options.generateRailsManifest | ||
description: options.description | ||
@@ -25,0 +26,0 @@ }); |
@@ -20,2 +20,3 @@ var fs = require('fs'); | ||
this.description = options.description; | ||
this.generateRailsManifest = options.generateRailsManifest; | ||
} | ||
@@ -70,2 +71,38 @@ | ||
Fingerprint.prototype.writeRailsManifest = function(destDir) { | ||
var assetRegex = /^assets\//, | ||
digestRegex = /-([0-9a-f]+)\.\w+$/, | ||
assetMap = {}, | ||
files = {}; | ||
for (var key in this.assetMap) { | ||
if (assetRegex.test(key)) { | ||
var fingerprintedPath = this.assetMap[key], | ||
assetlessKey = key.replace(assetRegex, ''), | ||
assetlessFingerprintedPath = fingerprintedPath.replace(assetRegex, ''), | ||
stats = fs.statSync(destDir + '/' + fingerprintedPath); | ||
files[assetlessFingerprintedPath] = { | ||
mtime: stats.mtime, | ||
logical_path: assetlessKey, | ||
digest: fingerprintedPath.match(digestRegex)[1], | ||
size: stats.size | ||
} | ||
assetMap[assetlessKey] = assetlessFingerprintedPath; | ||
} | ||
} | ||
var assets = { assets: assetMap, files: files }; | ||
fs.writeFileSync(destDir + '/assets/manifest.json', JSON.stringify(assets)); | ||
}; | ||
Fingerprint.prototype.write = function(readTree, destDir) { | ||
var self = this; | ||
return Filter.prototype.write.apply(this, arguments).then(function() { | ||
if (!!self.generateRailsManifest) { | ||
self.writeRailsManifest(destDir); | ||
} | ||
}); | ||
}; | ||
module.exports = Fingerprint; |
{ | ||
"name": "broccoli-asset-rev", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"description": "broccoli asset revisions (fingerprint)", | ||
@@ -5,0 +5,0 @@ "main": "lib/asset-rev.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9745
167