gulp-rev-append
Advanced tools
Comparing version 0.1.4 to 0.1.6
@@ -11,3 +11,2 @@ var File = require('gulp-util').File; | ||
console.log('load abs.'); | ||
this.indexFile = new File({ | ||
@@ -20,4 +19,5 @@ cwd: 'test/fixtures/', | ||
callback(); | ||
}); | ||
}; |
@@ -6,4 +6,2 @@ var chai = require('chai'); | ||
var FILE_DECL = /(?:href|src)=['|"]([^\s>"']+?)\?rev=([^\s>"']+?)['|"]/gi; | ||
module.exports = function() { | ||
@@ -36,3 +34,4 @@ 'use strict'; | ||
this.Then(/^The depencies are appended with a hash inline$/, function (callback) { | ||
var declarations = result.match(FILE_DECL); | ||
var fileDeclarationRegex = this.FILE_DECL; | ||
var declarations = result.match(fileDeclarationRegex); | ||
// defined in test/fixtures/static/index.html | ||
@@ -42,4 +41,4 @@ expect(declarations.length).to.equal(3); | ||
// plugin should change @@hash to hash based on file contents | ||
expect(FILE_DECL.exec(declarations[i])[2]).to.not.equal('@@hash'); | ||
FILE_DECL.lastIndex = 0; | ||
expect(fileDeclarationRegex.exec(declarations[i])[2]).to.not.equal('@@hash'); | ||
fileDeclarationRegex.lastIndex = 0; | ||
} | ||
@@ -46,0 +45,0 @@ callback(); |
@@ -10,2 +10,3 @@ 'use strict'; | ||
this.FILE_DECL = /(?:href=|src=|url\()['|"]([^\s>"']+?)\?rev=([^\s>"']+?)['|"]/gi; | ||
this.plugin = require('../../'); | ||
@@ -12,0 +13,0 @@ this.htmlFileContents = function(filename) { |
18
index.js
@@ -9,3 +9,3 @@ var fs = require('fs'); | ||
var FILE_DECL = /(?:href|src)=['|"]([^\s>"']+?)\?rev=([^\s>"']+?)['|"]/gi; | ||
var FILE_DECL = /(?:href=|src=|url\()['|"]([^\s>"']+?)\?rev=([^\s>"']+?)['|"]/gi; | ||
@@ -16,5 +16,5 @@ var revPlugin = function revPlugin() { | ||
var contents = file.contents.toString(); | ||
var lines = contents.split('\n'); | ||
var i, length = lines.length; | ||
var contents; | ||
var lines; | ||
var i, length; | ||
var line; | ||
@@ -26,5 +26,13 @@ var groups; | ||
if(!file) { | ||
throw new PluginError('gulp-rev', 'Missing fileName option for gulp-rev.'); | ||
throw new PluginError('gulp-rev-append', 'Missing file option for gulp-rev-append.'); | ||
} | ||
if(!file.contents) { | ||
throw new PluginError('gulp-rev-append', 'Missing file.contents required for modifying files using gulp-rev-append.'); | ||
} | ||
contents = file.contents.toString(); | ||
lines = contents.split('\n'); | ||
length = lines.length; | ||
for(i = 0; i < length; i++) { | ||
@@ -31,0 +39,0 @@ line = lines[i]; |
{ | ||
"name": "gulp-rev-append", | ||
"version": "0.1.4", | ||
"version": "0.1.6", | ||
"description": "Cache-busting plugin for gulp.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
55729
24
141