gulp-rev-all
Advanced tools
Comparing version 0.8.5 to 0.8.6
{ | ||
"name": "gulp-rev-all", | ||
"version": "0.8.5", | ||
"version": "0.8.6", | ||
"description": "Static asset revisioning by appending content hash to filenames: unicorn.css => unicorn.098f6bcd.css, also re-writes references in each file to new reved name.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -165,7 +165,7 @@ # [gulp](https://github.com/wearefractal/gulp)-rev-all [![Build Status](https://travis-ci.org/smysnk/gulp-rev-all.png?branch=master)](https://travis-ci.org/smysnk/gulp-rev-all) | ||
Don't update references in files matching these rules | ||
Don't update references matching these rules | ||
Type: `Array of (Regex and/or String)` | ||
Default: `[]` | ||
#### options.dontSearchReference | ||
#### options.dontSearchFile | ||
@@ -172,0 +172,0 @@ Don't search for references in files matching these rules |
@@ -17,3 +17,3 @@ var gracefulfs = require('graceful-fs'); | ||
'dontUpdateReference': [], | ||
'dontSearchReference': [], | ||
'dontSearchFile': [], | ||
'fileNameVersion': 'version.json', | ||
@@ -129,3 +129,3 @@ 'fileNameManifest': 'rev-manifest.json', | ||
// Don't try and resolve references in binary files or files that have been blacklisted | ||
if (this.Tool.is_binary_file(fileResolveReferencesIn) || !this.shouldSearchReference(fileResolveReferencesIn)) return; | ||
if (this.Tool.is_binary_file(fileResolveReferencesIn) || !this.shouldSearchFile(fileResolveReferencesIn)) return; | ||
@@ -331,3 +331,3 @@ var referenceGroupRelative = []; | ||
*/ | ||
Revisioner.prototype.shouldSearchReference = function (file) { | ||
Revisioner.prototype.shouldSearchFile = function (file) { | ||
@@ -343,4 +343,4 @@ var filename = this.Tool.get_relative_path(file.base, file.path); | ||
for (var i = this.options.dontSearchReference.length; i--;) { | ||
var regex = (this.options.dontSearchReference[i] instanceof RegExp) ? this.options.dontSearchReference[i] : new RegExp(this.options.dontSearchReference[i] + '$', 'ig'); | ||
for (var i = this.options.dontSearchFile.length; i--;) { | ||
var regex = (this.options.dontSearchFile[i] instanceof RegExp) ? this.options.dontSearchFile[i] : new RegExp(this.options.dontSearchFile[i] + '$', 'ig'); | ||
if (filename.match(regex)) { | ||
@@ -347,0 +347,0 @@ return false; |
42
test.js
@@ -312,2 +312,3 @@ var RevAll = require('./index'); | ||
String(files['/index.html'].contents).should.not.match(/\.[a-z0-9]{8}\.html/g); | ||
String(files['/index.html'].contents).should.match(/\.[a-z0-9]{8}\.jpg/g); | ||
done(); | ||
@@ -331,2 +332,3 @@ | ||
String(files['/index.html'].contents).should.not.match(/\.[a-z0-9]{8}\.html/g); | ||
String(files['/index.html'].contents).should.match(/\.[a-z0-9]{8}\.jpg/g); | ||
done(); | ||
@@ -342,2 +344,42 @@ | ||
describe('dontSearchFile', function () { | ||
it('should not update reference when specified with file extension', function (done) { | ||
setup({ | ||
dontSearchFile: ['.html'] | ||
}); | ||
streamRevision.on('data', function (file) { }); | ||
streamRevision.on('end', function () { | ||
String(files['/index.html'].contents).should.not.match(/\.[a-z0-9]{8}\./g); | ||
done(); | ||
}); | ||
Tool.write_glob_to_stream(base, 'test/fixtures/config1/**', streamRevision); | ||
}); | ||
it('should not update reference when specified with file regex', function (done) { | ||
setup({ | ||
dontSearchFile: [ /.html$/g ] | ||
}); | ||
streamRevision.on('data', function (file) {}); | ||
streamRevision.on('end', function () { | ||
String(files['/index.html'].contents).should.not.match(/\.[a-z0-9]{8}\./g); | ||
done(); | ||
}); | ||
Tool.write_glob_to_stream(base, 'test/fixtures/config1/**', streamRevision); | ||
}); | ||
}); | ||
}); | ||
@@ -344,0 +386,0 @@ |
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
732545
1513