broccoli-asset-rev
Advanced tools
Comparing version 2.3.0 to 2.4.0
@@ -12,2 +12,10 @@ var fs = require('fs'); | ||
var MatcherCollection = require('matcher-collection'); | ||
var MatchNothing = { | ||
match: function() { | ||
return false; | ||
} | ||
}; | ||
function Fingerprint(inputNode, options) { | ||
@@ -27,3 +35,2 @@ if (!(this instanceof Fingerprint)) { | ||
this.assetMap = options.assetMap || {}; | ||
this.exclude = options.exclude || []; | ||
this.fingerprintAssetMap = options.fingerprintAssetMap || false; | ||
@@ -36,2 +43,8 @@ this.generateAssetMap = options.generateAssetMap; | ||
if (Array.isArray(options.exclude)) { | ||
this.exclude = new MatcherCollection(options.exclude); | ||
} else { | ||
this.exclude = MatchNothing; | ||
} | ||
if (typeof options.customHash === 'function') { | ||
@@ -50,4 +63,4 @@ this.customHash = ''; | ||
Fingerprint.prototype.canProcessFile = function (relativePath) { | ||
for (var i = 0; i < this.exclude.length; i++) { | ||
if (relativePath.indexOf(this.exclude[i]) !== -1) { | ||
for (var i = 0; i < this.exclude.matchers.length; i++) { | ||
if (relativePath.indexOf(this.exclude.matchers[i].pattern) !== -1) { | ||
return false; | ||
@@ -57,2 +70,6 @@ } | ||
if (this.exclude.match(relativePath)) { | ||
return false; | ||
} | ||
return Filter.prototype.getDestFilePath.apply(this, arguments) != null; | ||
@@ -177,3 +194,3 @@ }; | ||
if (this.exclude.indexOf('manifest.json') === -1) { | ||
if (!this.exclude.match('manifest.json')) { | ||
var hash = this.hashFn(contents); | ||
@@ -180,0 +197,0 @@ fileName += '-' + hash; |
{ | ||
"name": "broccoli-asset-rev", | ||
"version": "2.3.0", | ||
"version": "2.4.0", | ||
"description": "broccoli asset revisions (fingerprint)", | ||
@@ -36,2 +36,3 @@ "main": "lib/asset-rev.js", | ||
"json-stable-stringify": "^1.0.0", | ||
"matcher-collection": "^1.0.1", | ||
"rsvp": "~3.0.6" | ||
@@ -38,0 +39,0 @@ }, |
@@ -41,3 +41,3 @@ #broccoli-asset-rev | ||
- `extensions` - Default: `['js', 'css', 'png', 'jpg', 'gif', 'map']` - The file types to add md5 checksums. | ||
- `exclude` - Default: `[]` - An array of strings. If a filename contains any item in the exclude array, it will not be fingerprinted. | ||
- `exclude` - Default: `[]` - An array of globs. If a filename contains any item in the exclude array, it will not be fingerprinted. | ||
- `replaceExtensions` - Default: `['html', 'css', 'js']` - The file types to replace source code with new checksum file names. | ||
@@ -77,5 +77,5 @@ - `prepend` - Default: `''` - A string to prepend to all of the assets. Useful for CDN urls like `https://subdomain.cloudfront.net/` | ||
- `enabled` - Default: `app.env === 'production'` - Boolean. Enables fingerprinting if true. **True by default if current environment is production.** | ||
- `exclude` - Default: `[]` - An array of strings. If a filename contains any item in the exclude array, it will not be fingerprinted. | ||
- `exclude` - Default: `[]` - An array of globs. If a filename contains any item in the exclude array, it will not be fingerprinted. | ||
- `extensions` - Default: `['js', 'css', 'png', 'jpg', 'gif', 'map']` - The file types to add md5 checksums. | ||
- `prepend` - Default: `''` - A string to prepend to all of the assets. Useful for CDN urls like `https://subdomain.cloudfront.net/` | ||
- `replaceExtensions` - Default: `['html', 'css', 'js']` - The file types to replace source code with new checksum file names. |
@@ -108,2 +108,32 @@ var fs = require('fs'); | ||
it('accepts a string as exclude parameter', function () { | ||
var sourcePath = 'tests/fixtures/exclude'; | ||
var node = new AssetRev(sourcePath + '/input', { | ||
extensions: ['js', 'css', 'png', 'jpg', 'gif', 'map', 'ttf'], | ||
exclude: ['assets/fonts'], | ||
replaceExtensions: ['html', 'js', 'css'] | ||
}); | ||
builder = new broccoli.Builder(node); | ||
return builder.build().then(function(graph) { | ||
confirmOutput(graph.directory, sourcePath + '/output'); | ||
}); | ||
}); | ||
it("accepts a glob as exclude parameter", function() { | ||
var sourcePath = 'tests/fixtures/exclude'; | ||
var node = new AssetRev(sourcePath + '/input', { | ||
extensions: ['js', 'css', 'png', 'jpg', 'gif', 'map', 'ttf'], | ||
exclude: ['assets/fonts/**/*'], | ||
replaceExtensions: ['html', 'js', 'css'] | ||
}); | ||
builder = new broccoli.Builder(node); | ||
return builder.build().then(function(graph) { | ||
confirmOutput(graph.directory, sourcePath + '/output'); | ||
}); | ||
}); | ||
it("uses a custom path for the rails-style manifest", function () { | ||
@@ -110,0 +140,0 @@ var sourcePath = 'tests/fixtures/basic'; |
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
75269
116
792
5
+ Addedmatcher-collection@^1.0.1