broccoli-asset-rev
Advanced tools
Comparing version 2.0.3 to 2.0.4
@@ -24,3 +24,3 @@ var fs = require('fs'); | ||
if (typeof options.customHash === 'function') { | ||
this.customHash = null; | ||
this.customHash = ''; | ||
this.hashFn = options.customHash; | ||
@@ -59,6 +59,10 @@ } else { | ||
Fingerprint.prototype.getDestFilePath = function (relativePath) { | ||
if (Filter.prototype.getDestFilePath.apply(this, arguments)) { | ||
var destFilePath = Filter.prototype.getDestFilePath.apply(this, arguments); | ||
if (destFilePath) { | ||
if (this.assetMap[relativePath]) { | ||
return this.assetMap[relativePath]; | ||
} | ||
if (this.customHash === null) { | ||
return this.assetMap[relativePath] = destFilePath; | ||
} | ||
@@ -65,0 +69,0 @@ var tmpPath = path.join(this._srcDir, relativePath); |
{ | ||
"name": "broccoli-asset-rev", | ||
"version": "2.0.3", | ||
"version": "2.0.4", | ||
"description": "broccoli asset revisions (fingerprint)", | ||
@@ -5,0 +5,0 @@ "main": "lib/asset-rev.js", |
@@ -46,3 +46,12 @@ #broccoli-asset-rev | ||
- `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. | ||
- `generateAssetMap` - Default: false. If true, will generate a `assetMap.json` file in a `assets` directory on the output tree. This file contains a mapping of the original asset name to the fingerprinted asset, like the following: | ||
```js | ||
{ | ||
assets: { | ||
css/file1.css: css/file1-sdaa7d6a87d6ada78ds.css, | ||
images/image1.png: images/image1-sdaa7d6a87d6ada78ds.css, } | ||
} | ||
``` | ||
## Ember CLI addon usage | ||
@@ -49,0 +58,0 @@ |
@@ -40,3 +40,3 @@ var fs = require('fs'); | ||
var tree = assetRev(sourcePath + '/input', { | ||
extensions: ['js', 'css', 'png', 'jpg', 'gif'], | ||
extensions: ['js', 'css', 'png', 'jpg', 'gif', 'map'], | ||
replaceExtensions: ['html', 'js', 'css'] | ||
@@ -57,3 +57,3 @@ }); | ||
var tree = assetRev(merged, { | ||
extensions: ['js', 'css', 'png', 'jpg', 'gif'], | ||
extensions: ['js', 'css', 'png', 'jpg', 'gif', 'map'], | ||
replaceExtensions: ['html', 'js', 'css'] | ||
@@ -72,3 +72,3 @@ }); | ||
var tree = assetRev(sourcePath + '/input', { | ||
extensions: ['js', 'css', 'png', 'jpg', 'gif'], | ||
extensions: ['js', 'css', 'png', 'jpg', 'gif', 'map'], | ||
replaceExtensions: ['html', 'js', 'css'], | ||
@@ -84,2 +84,33 @@ prepend: 'https://foobar.cloudfront.net/' | ||
it('skips fingerprint and prepends when set and customHash is null', function () { | ||
var sourcePath = 'tests/fixtures/prepend'; | ||
var tree = assetRev(sourcePath + '/input', { | ||
extensions: ['js', 'css', 'png', 'jpg', 'gif', 'map'], | ||
replaceExtensions: ['html', 'js', 'css'], | ||
prepend: 'https://foobar.cloudfront.net/', | ||
customHash: null | ||
}); | ||
builder = new broccoli.Builder(tree); | ||
return builder.build().then(function(graph) { | ||
confirmOutput(graph.directory, sourcePath + '/output-customHash-null'); | ||
}); | ||
}); | ||
it('skips fingerprint when customHash is null', function () { | ||
var sourcePath = 'tests/fixtures/customHash-null'; | ||
var tree = assetRev(sourcePath + '/input-output', { | ||
extensions: ['js', 'css', 'png', 'jpg', 'gif', 'map'], | ||
replaceExtensions: ['html', 'js', 'css'], | ||
customHash: null | ||
}); | ||
builder = new broccoli.Builder(tree); | ||
return builder.build().then(function(graph) { | ||
confirmOutput(graph.directory, sourcePath + '/input-output'); | ||
}); | ||
}); | ||
it('replaces the correct match for the file extension', function () { | ||
@@ -86,0 +117,0 @@ var sourcePath = 'tests/fixtures/extensions'; |
Sorry, the diff of this file is not supported yet
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
48129
79
458
74