Comparing version
44
index.js
var crypto = require('crypto'), | ||
through2 = require('through2'), | ||
gutil = require('gulp-util'), | ||
assign = require('lodash.assign'), | ||
template = require('lodash.template'), | ||
path = require('path') | ||
Promise = require('es6-promise').Promise; | ||
gutil = require('gulp-util'), | ||
assign = require('lodash.assign'), | ||
template = require('lodash.template'), | ||
path = require('path'), | ||
Promise = require('es6-promise').Promise, | ||
fs = require('fs'); | ||
@@ -25,3 +26,3 @@ var exportObj = function(options) { | ||
var fileExt = path.extname(file.relative), | ||
fileName = path.basename(file.relative, fileExt); | ||
fileName = path.basename(file.relative, fileExt); | ||
@@ -73,10 +74,10 @@ var hasher = crypto.createHash(options.algorithm); | ||
if (append && ! origManifestContents[manifestPath]) { | ||
try { | ||
var content = fs.readFileSync(manifestPath, {encoding: 'utf8'}); | ||
origManifestContents[manifestPath] = JSON.parse(content); | ||
} catch (e) { | ||
origManifestContents[manifestPath] = {}; | ||
} | ||
} | ||
if (append && ! origManifestContents[manifestPath]) { | ||
try { | ||
var content = fs.readFileSync(manifestPath, {encoding: 'utf8'}); | ||
origManifestContents[manifestPath] = JSON.parse(content); | ||
} catch (e) { | ||
origManifestContents[manifestPath] = {}; | ||
} | ||
} | ||
@@ -95,8 +96,5 @@ return through2.obj( | ||
function(cb) { | ||
var contents = {}, | ||
finish; | ||
var finish = function(data) { | ||
origManifestContents[manifestPath] = data; | ||
finish = function(data) { | ||
origManifestContents[manifestPath] = data; | ||
this.push(new gutil.File({ | ||
@@ -111,6 +109,6 @@ path: manifestPath, | ||
if (append) { | ||
appendQueue.then(new Promise(function(resolve, reject) { | ||
finish(assign({}, origManifestContents[manifestPath], manifest)); | ||
resolve(); | ||
})); | ||
appendQueue.then(new Promise(function(resolve) { | ||
finish(assign({}, origManifestContents[manifestPath], manifest)); | ||
resolve(); | ||
})); | ||
} else { | ||
@@ -117,0 +115,0 @@ finish(manifest); |
{ | ||
"name": "gulp-hash", | ||
"version": "3.0.5", | ||
"version": "3.0.6", | ||
"description": "Cachebust your assets by adding a hash to the filename", | ||
"license": "MIT", | ||
"keywords": [ | ||
@@ -6,0 +7,0 @@ "cache", |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
7280
19.99%8
33.33%97
-1.02%1
Infinity%