Skip to content

Commit

Permalink
Fix gulp-util
Browse files Browse the repository at this point in the history
and fix the new vinyl removing pipe method
  • Loading branch information
migolo committed Jan 13, 2018
1 parent 17e6ca0 commit c73783c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 13 deletions.
18 changes: 12 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
@@ -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'),
Expand All @@ -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);
Expand All @@ -48,12 +49,17 @@ 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()) {
//console.dir(file);
stream.end(file.contents);
} else {
stream.end();
}
});
};
Expand Down Expand Up @@ -126,7 +132,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))
}));
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 0 additions & 1 deletion test/algorithms.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
8 changes: 4 additions & 4 deletions test/manifest.js
Original file line number Diff line number Diff line change
@@ -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'),
Expand Down Expand Up @@ -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'
});
Expand Down

0 comments on commit c73783c

Please sign in to comment.