gulp-rev-all
Advanced tools
Comparing version 0.8.11 to 0.8.12
{ | ||
"name": "gulp-rev-all", | ||
"version": "0.8.11", | ||
"version": "0.8.12", | ||
"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", |
@@ -82,5 +82,5 @@ var Gutil = require('gulp-util'); | ||
var levelsBase = this.pathBase.split('/'); | ||
var levelsFile = file.base.split('/'); | ||
var levelsBase = this.pathBase.split(/[\/|\\]/); | ||
var levelsFile = file.base.split(/[\/|\\]/); | ||
var common = []; | ||
@@ -96,3 +96,4 @@ for (var level = 0, length = levelsFile.length; level < length; level++) { | ||
this.pathBase = common.join('/'); | ||
if (common[common.length - 1] != '') common.push(''); | ||
this.pathBase = common.join('/'); | ||
@@ -286,3 +287,3 @@ } | ||
var pathReferenceReplace; | ||
if (reference.file.revFilenameExtOriginal == '.js' && !reference.path.match(/.js$/)) { | ||
if (reference.file.revFilenameExtOriginal == '.js' && !reference.path.match(/\.js$/)) { | ||
pathReferenceReplace = reference.path.substr(0, reference.path.length - reference.file.revFilenameOriginal.length); | ||
@@ -289,0 +290,0 @@ pathReferenceReplace += reference.file.revFilename.substr(0, reference.file.revFilename.length - 3); |
26
test.js
@@ -154,3 +154,3 @@ var RevAll = require('./index'); | ||
String(files['/index.html'].contents).should.not.match(/favicon\.[a-z0-9]{8}\.ico/g); | ||
String(files['/index.html'].contents).should.not.match(/"favicon\.[a-z0-9]{8}\.ico"/g); | ||
done(); | ||
@@ -250,3 +250,3 @@ | ||
files['/nested/index.html'].path.should.not.match(/nested\/index\.html$/); | ||
files['/nested/index.html'].path.should.not.match(/\/nested\/index\.html$/); | ||
files['/index.html'].path.should.not.match(/index\.[a-z0-9]{8}\.html$/); | ||
@@ -514,4 +514,4 @@ | ||
String(files['/index.html'].contents).match(/\/script\/main\.[a-z0-9]{8}\.js/g); | ||
String(files['/index.html'].contents).match(/\/lib\/require\.[a-z0-9]{8}\.js/g); | ||
String(files['/index.html'].contents).match(/"\/script\/main\.[a-z0-9]{8}\.js"/g); | ||
String(files['/index.html'].contents).match(/"\/lib\/require\.[a-z0-9]{8}\.js"/g); | ||
@@ -533,3 +533,3 @@ done(); | ||
String(files['/index.html'].contents).match(/\/img\/image1\.[a-z0-9]{8}\.jpg/g); | ||
String(files['/index.html'].contents).match(/"\/img\/image1\.[a-z0-9]{8}\.jpg"/g); | ||
done(); | ||
@@ -549,3 +549,3 @@ | ||
String(files['/index.html'].contents).match(/\/img\/image2\.[a-z0-9]{8}\.jpg/g); | ||
String(files['/index.html'].contents).match(/'\/img\/image2\.[a-z0-9]{8}\.jpg'/g); | ||
done(); | ||
@@ -863,3 +863,3 @@ | ||
Tool.join_path('\\first\\second', 'images.png').should.equal('/first/second/images.png'); | ||
Tool.join_path('d:\\first\\second', 'images.png').should.equal('/first/second/images.png'); | ||
@@ -900,4 +900,4 @@ }); | ||
Tool.get_relative_path('\\base', '\\base\\sub\\index.html').should.equal('/sub/index.html'); | ||
Tool.get_relative_path('\\base\\', '\\base\\sub\\index.html').should.equal('/sub/index.html'); | ||
Tool.get_relative_path('c:\\base', 'c:\\base\\sub\\index.html').should.equal('/sub/index.html'); | ||
Tool.get_relative_path('c:\\base\\', 'c:\\base\\sub\\index.html').should.equal('/sub/index.html'); | ||
@@ -908,4 +908,4 @@ }); | ||
Tool.get_relative_path('\\base', '\\base\\sub\\index.html', true).should.equal('sub/index.html'); | ||
Tool.get_relative_path('\\base\\', '\\base\\sub\\index.html', true).should.equal('sub/index.html'); | ||
Tool.get_relative_path('d:\\base', 'd:\\base\\sub\\index.html', true).should.equal('sub/index.html'); | ||
Tool.get_relative_path('d:\\base\\', 'd:\\base\\sub\\index.html', true).should.equal('sub/index.html'); | ||
@@ -916,4 +916,4 @@ }); | ||
Tool.get_relative_path('\\base\\sub', '\\base\\sub\\index.html', true).should.equal('index.html'); | ||
Tool.get_relative_path('\\base\\sub\\', '\\base\\sub\\index.html', true).should.equal('index.html'); | ||
Tool.get_relative_path('e:\\base\\sub', 'e:\\base\\sub\\index.html', true).should.equal('index.html'); | ||
Tool.get_relative_path('e:\\base\\sub\\', 'e:\\base\\sub\\index.html', true).should.equal('index.html'); | ||
@@ -920,0 +920,0 @@ }); |
19
tool.js
@@ -20,3 +20,3 @@ var Path = require('path'); | ||
var path = Path.join(directory, filename).replace(/\\/g, '/'); | ||
var path = Path.join(directory, filename).replace(/^[a-z]:\\/i, '/').replace(/\\/g, '/'); | ||
return (path.indexOf('/') == 0) ? path : '/' + path; | ||
@@ -35,4 +35,4 @@ | ||
// Sanitize inputs, convert windows to posix style slashes, remove trailing slash off base is there is one | ||
base = base.replace(/\\/g, '/').replace(/\/$/g, ''); | ||
path = path.substr(base.length).replace(/\\/g, '/'); | ||
base = base.replace(/^[a-z]:/i, '').replace(/\\/g, '/').replace(/\/$/g, ''); | ||
path = path.replace(/^[a-z]:/i, '').replace(/\\/g, '/').substr(base.length); | ||
@@ -107,8 +107,9 @@ if (path.indexOf('/') == 0 && noStartingSlash) { | ||
// ../second/index.html | ||
representations.push(Path.relative(pathFile, pathCurrentReference) + '/' + Path.basename(fileCurrentReference.revPathOriginal)); | ||
var relPath = Path.relative(pathFile, pathCurrentReference); | ||
relPath = relPath.replace(/\\/g, '/'); | ||
representations.push(relPath + '/' + Path.basename(fileCurrentReference.revPathOriginal)); | ||
} | ||
// Only care about trying to match shorthand javascript includes in javascript file context | ||
if (file.revPathOriginal.match(/.js$/ig)) { | ||
if (file.revPathOriginal.match(/\.js$/ig)) { | ||
// Create alternative representations for javascript files for frameworks that omit the .js extension | ||
@@ -118,3 +119,3 @@ for (var i = 0, length = representations.length; i < length; i++) { | ||
// Skip non-javascript files, also ensure the folder has at least one directory in it (so we don't end up with super short single words) | ||
if (!representations[i].match(/.js$/ig) || !representations[i].match(/\//ig)) continue; | ||
if (!representations[i].match(/\.js$/ig) || !representations[i].match(/\//ig)) continue; | ||
@@ -150,3 +151,3 @@ representations.push(representations[i].substr(0, representations[i].length - 3)); | ||
// Only care about trying to match shorthand javascript includes in javascript file context | ||
if (file.revPathOriginal.match(/.js$/ig)) { | ||
if (file.revPathOriginal.match(/\.js$/ig)) { | ||
// Create alternative representations for javascript files for frameworks that omit the .js extension | ||
@@ -156,3 +157,3 @@ for (var i = 0, length = representations.length; i < length; i++) { | ||
// Skip non-javascript files, also ensure the folder has at least one directory in it (so we don't end up with super short single words) | ||
if (!representations[i].match(/.js$/ig) || !representations[i].match(/\//ig)) continue; | ||
if (!representations[i].match(/\.js$/ig) || !representations[i].match(/\//ig)) continue; | ||
@@ -159,0 +160,0 @@ representations.push(representations[i].substr(0, representations[i].length - 3)); |
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
732351
1490