Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix gulp-util deprecation #27

Merged
merged 2 commits into from
Jan 14, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix gulp-util
and fix the new vinyl removing pipe method
migolo committed Jan 13, 2018
commit c73783c7d330614ad51f8802affa7ce690de547b
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'),
@@ -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,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();
}
});
};
@@ -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))
}));
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
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');
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'),
@@ -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'
});