broccoli-asset-rev
Advanced tools
Comparing version 2.1.3 to 2.2.0
@@ -17,2 +17,3 @@ var Fingerprint = require('./fingerprint'); | ||
this.exclude = options.exclude || []; | ||
this.fingerprintAssetMap = options.fingerprintAssetMap || false; | ||
this.generateAssetMap = options.generateAssetMap; | ||
@@ -19,0 +20,0 @@ this.generateRailsManifest = options.generateRailsManifest; |
@@ -27,2 +27,3 @@ var fs = require('fs'); | ||
this.exclude = options.exclude || []; | ||
this.fingerprintAssetMap = options.fingerprintAssetMap || false; | ||
this.generateAssetMap = options.generateAssetMap; | ||
@@ -100,2 +101,5 @@ this.generateRailsManifest = options.generateRailsManifest; | ||
var contents = new Buffer(stringify(toWrite)); | ||
var fileName = this.fingerprintAssetMap ? 'assetMap-' + this.hashFn(contents) + '.json' : 'assetMap.json'; | ||
if (!fs.existsSync(destDir + '/assets')) { | ||
@@ -105,3 +109,4 @@ fs.mkdirSync(destDir + '/assets'); | ||
fs.writeFileSync(destDir + '/assets/assetMap.json', stringify(toWrite)); | ||
fs.writeFileSync(destDir + '/assets/' + fileName, contents); | ||
this.assetMap['assets/assetMap.json'] = 'assets/' + fileName; | ||
}; | ||
@@ -108,0 +113,0 @@ |
{ | ||
"name": "broccoli-asset-rev", | ||
"version": "2.1.3", | ||
"version": "2.2.0", | ||
"description": "broccoli asset revisions (fingerprint)", | ||
@@ -5,0 +5,0 @@ "main": "lib/asset-rev.js", |
@@ -83,3 +83,3 @@ var fs = require('fs'); | ||
var actualFiles = walkSync(graph.directory); | ||
var pathPresent = confirmPathPresent(actualFiles, /manifest-[0-9a-f]{32}.json/); | ||
var pathPresent = confirmPathPresent(actualFiles, /manifest-[0-9a-f]{32}\.json/); | ||
@@ -103,3 +103,3 @@ assert(pathPresent, "manifest file not found"); | ||
var actualFiles = walkSync(graph.directory); | ||
var pathPresent = confirmPathPresent(actualFiles, /manifest.json/); | ||
var pathPresent = confirmPathPresent(actualFiles, /manifest\.json/); | ||
@@ -110,2 +110,39 @@ assert(pathPresent, "manifest file not found"); | ||
it('generates an asset map if requested', function () { | ||
var sourcePath = 'tests/fixtures/basic'; | ||
var node = new AssetRev(sourcePath + '/input', { | ||
extensions: ['js', 'css', 'png', 'jpg', 'gif'], | ||
generateAssetMap: true, | ||
replaceExtensions: ['html', 'js', 'css'] | ||
}); | ||
builder = new broccoli.Builder(node); | ||
return builder.build().then(function(graph) { | ||
var actualFiles = walkSync(graph.directory); | ||
var pathPresent = confirmPathPresent(actualFiles, /assetMap\.json/); | ||
assert(pathPresent, "asset map file not found"); | ||
}); | ||
}); | ||
it("fingerprints the asset map if requested", function () { | ||
var sourcePath = 'tests/fixtures/basic'; | ||
var node = new AssetRev(sourcePath + '/input', { | ||
extensions: ['js', 'css', 'png', 'jpg', 'gif'], | ||
fingerprintAssetMap: true, | ||
generateAssetMap: true, | ||
replaceExtensions: ['html', 'js', 'css'] | ||
}); | ||
builder = new broccoli.Builder(node); | ||
return builder.build().then(function(graph) { | ||
var actualFiles = walkSync(graph.directory); | ||
var pathPresent = confirmPathPresent(actualFiles, /assetMap-[0-9a-f]{32}\.json/); | ||
assert(pathPresent, "fingerprinted asset map file not found"); | ||
}); | ||
}); | ||
it('will prepend if set', function () { | ||
@@ -112,0 +149,0 @@ var sourcePath = 'tests/fixtures/prepend'; |
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
65660
642