Remove .pipe method
phated opened this issue · 5 comments
This method seems like really old cruft that doesn't belong.
A few reasons I think it should be removed:
- Vinyl isn't actually a stream, so having a
pipe
method could confuse duck-typing - The pattern for dealing with streams in plugins is:
if (file.isStream()) {
file.contents = file.contents.pipe(transform());
}
@contra do you agree?
Are there plans to replace .pipe()
with another method? I know it's a small increase of 1 line to 3 lines but it winds up bloating all downstream plugins =/ (e.g. now I'm responsible for testing buffers/streams are handled consistently)
With the removal of this bad pipe function many gulp plugins do not work anymore. Trying to fix one with this old code:
file // instance of Vinyl
.pipe(split2())
.pipe(through(someFunction(), function(callback) {
if (content.length) {
file.contents = new Buffer(content.join('\n'));
that.push(file);
}
// callback();
cb();
}));
file
comes from var stream = through2.obj(function(file, enc, cb) {
How to fix this best?
@binarykitchen This ticket was for the removal of a really old function file.pipe
that was never really used or adopted. file.contents = file.contents.pipe(whatever)
is the replacement for this case. There are a bunch of issues with your example code, but that's more something you should get help with on StackOverflow or similar.
Right, thanks