broccoli-asset-rev
Advanced tools
Comparing version 2.0.4 to 2.0.5
@@ -124,4 +124,10 @@ var fs = require('fs'); | ||
var contents = new Buffer(JSON.stringify(assets)); | ||
var hash = this.hashFn(contents); | ||
fs.writeFileSync(destDir + '/assets/manifest-' + hash + '.json', contents); | ||
var fileName = 'manifest'; | ||
if (this.exclude.indexOf('manifest.json') === -1) { | ||
var hash = this.hashFn(contents); | ||
fileName += '-' + hash; | ||
} | ||
fs.writeFileSync(destDir + '/assets/' + fileName + '.json', contents); | ||
}; | ||
@@ -128,0 +134,0 @@ |
{ | ||
"name": "broccoli-asset-rev", | ||
"version": "2.0.4", | ||
"version": "2.0.5", | ||
"description": "broccoli asset revisions (fingerprint)", | ||
@@ -5,0 +5,0 @@ "main": "lib/asset-rev.js", |
@@ -44,3 +44,3 @@ #broccoli-asset-rev | ||
- `prepend` - Default: `''` - A string to prepend to all of the assets. Useful for CDN urls like `https://subdomain.cloudfront.net/` | ||
- `generateRailsManifest` - Default: none - If true, will generate a `manifest.json` to be used by Sprockets for the Rails Asset Pipeline | ||
- `generateRailsManifest` - Default: none - If true, will generate a `manifest.json` to be used by Sprockets for the Rails Asset Pipeline. The manifest will be fingerprinted by default but this can be avoided by adding `'manifest.json'` to the `exclude` list. | ||
- `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. | ||
@@ -47,0 +47,0 @@ - `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: |
@@ -29,2 +29,8 @@ var fs = require('fs'); | ||
function confirmPathPresent(list, pattern) { | ||
return list.some(function(item) { | ||
return item.search(pattern) !== -1; | ||
}); | ||
} | ||
describe('broccoli-asset-rev', function() { | ||
@@ -67,2 +73,39 @@ afterEach(function() { | ||
it('generates a rails-style asset manifest if requested', function () { | ||
var sourcePath = 'tests/fixtures/basic'; | ||
var tree = assetRev(sourcePath + '/input', { | ||
extensions: ['js', 'css', 'png', 'jpg', 'gif'], | ||
generateRailsManifest: true, | ||
replaceExtensions: ['html', 'js', 'css'] | ||
}); | ||
builder = new broccoli.Builder(tree); | ||
return builder.build().then(function(graph) { | ||
var actualFiles = walkSync(graph.directory); | ||
var pathPresent = confirmPathPresent(actualFiles, /manifest-[0-9a-f]{32}.json/); | ||
assert(pathPresent, "manifest file not found"); | ||
}); | ||
}); | ||
it("doesn't fingerprint rails-style manifest if excluded", function () { | ||
var sourcePath = 'tests/fixtures/basic'; | ||
var tree = assetRev(sourcePath + '/input', { | ||
extensions: ['js', 'css', 'png', 'jpg', 'gif'], | ||
exclude: ['manifest.json'], | ||
generateRailsManifest: true, | ||
replaceExtensions: ['html', 'js', 'css'] | ||
}); | ||
builder = new broccoli.Builder(tree); | ||
return builder.build().then(function(graph) { | ||
var actualFiles = walkSync(graph.directory); | ||
var pathPresent = confirmPathPresent(actualFiles, /manifest.json/); | ||
assert(pathPresent, "manifest file not found"); | ||
}); | ||
}); | ||
it('will prepend if set', function () { | ||
@@ -69,0 +112,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
49753
496