17
index.js
var crypto = require('crypto'), | ||
through2 = require('through2'), | ||
gutil = require('gulp-util'), | ||
Vinyl = require('vinyl'), | ||
assign = require('lodash.assign'), | ||
@@ -30,3 +30,4 @@ template = require('lodash.template'), | ||
var piped = file.pipe(through2( | ||
var opt = {end: true}; | ||
var stream = through2( | ||
function(chunk, enc, updateCb) { | ||
@@ -52,8 +53,12 @@ hasher.update(chunk); | ||
}.bind(this) | ||
)); | ||
); | ||
if (file.isStream()) { | ||
file.contents = file.contents.pipe(stream, opt); | ||
var newContents = through2(); | ||
piped.pipe(newContents); | ||
file.contents.pipe(newContents); | ||
file.contents = newContents; | ||
} else if (file.isBuffer()) { | ||
stream.end(file.contents); | ||
} else { | ||
stream.end(); | ||
} | ||
@@ -131,3 +136,3 @@ }); | ||
this.push(new gutil.File({ | ||
this.push(new Vinyl({ | ||
path: manifestPath, | ||
@@ -134,0 +139,0 @@ contents: new Buffer(JSON.stringify(origManifestContents[manifestPath], undefined, space)) |
{ | ||
"name": "gulp-hash", | ||
"version": "4.1.1", | ||
"version": "4.2.0", | ||
"description": "Cachebust your assets by adding a hash to the filename", | ||
@@ -47,6 +47,6 @@ "license": "MIT", | ||
"es6-promise": "^2.1.1", | ||
"gulp-util": "^2.2.17", | ||
"lodash.assign": "^2.4.1", | ||
"lodash.template": "^2.4.1", | ||
"through2": "^2.0.0" | ||
"through2": "^2.0.0", | ||
"vinyl": "^2.1.0" | ||
}, | ||
@@ -53,0 +53,0 @@ "devDependencies": { |
10393
1.46%134
4.69%