diff --git a/index.js b/index.js index d039987..52d29c2 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,6 @@ var crypto = require('crypto'), through2 = require('through2'), - gutil = require('gulp-util'), + Vinyl = require('vinyl'), assign = require('lodash.assign'), template = require('lodash.template'), path = require('path'), @@ -27,7 +27,8 @@ var exportObj = function(options) { var hasher = crypto.createHash(options.algorithm); - var piped = file.pipe(through2( + var opt = {end: true}; + var stream = through2( function(chunk, enc, updateCb) { hasher.update(chunk); updateCb(null, chunk); @@ -48,12 +49,16 @@ var exportObj = function(options) { cb(); flushCb(); }.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(); } }); }; @@ -126,7 +131,7 @@ exportObj.manifest = function(manifestPath, options) { origManifestContents[manifestPath] = data; - this.push(new gutil.File({ + this.push(new Vinyl({ path: manifestPath, contents: new Buffer(JSON.stringify(origManifestContents[manifestPath], undefined, space)) })); diff --git a/package.json b/package.json index 8b22dc1..7c90483 100644 --- a/package.json +++ b/package.json @@ -44,10 +44,10 @@ "main": "./index.js", "dependencies": { "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" }, "devDependencies": { "gulp": "^3.9.0", diff --git a/test/algorithms.js b/test/algorithms.js index 659302a..ac89320 100644 --- a/test/algorithms.js +++ b/test/algorithms.js @@ -1,7 +1,6 @@ var path = require('path'), fs = require('fs'), gulp = require('gulp'), - gutil = require('gulp-util'), assert = require('assert'), through2 = require('through2'), hash = require('../index.js'); diff --git a/test/manifest.js b/test/manifest.js index 0eaaf3a..5027cc1 100644 --- a/test/manifest.js +++ b/test/manifest.js @@ -1,6 +1,6 @@ var path = require('path'), gulp = require('gulp'), - gutil = require('gulp-util'), + Vinyl = require('vinyl'), through2 = require('through2'), assert = require('assert'), hash = require('../index.js'), @@ -48,21 +48,21 @@ describe('hash.manifest()', function() { it('the append option should work and use a queue', function(done) { hash.resetManifestCache(); - var fakeFile = new gutil.File({ + var fakeFile = new Vinyl({ contents: new Buffer('Hello'), path: 'file-f7ff9e8b.txt' }); fakeFile.origPath = 'file.txt'; - var fakeFile2 = new gutil.File({ + var fakeFile2 = new Vinyl({ contents: new Buffer('Hello'), path: 'foo-123.txt' }); fakeFile2.origPath = 'foo.txt'; - var fakeFile3 = new gutil.File({ + var fakeFile3 = new Vinyl({ contents: new Buffer('Hello'), path: 'foo-456.txt' });