How do I prepend a stream to another? #255
Copy link
Copy link
Closed
Description
Activity
You can use streamqueue for that. The problem is that gulp is outputting old streams and streamqueue had to go through quite some hackery to work with it, loosing some of the efficiency of streams in the process :/
Example:
fixed example below
Doesn't work. streamqueue only works with string/buffer chunks.
Shit. I forgot an option flag :) You need to specify
{ objectMode: true }:var gulp = require('gulp'); var concat = require('gulp-concat'); var streamqueue = require('streamqueue'); gulp.task('default', function () { return streamqueue({ objectMode: true }, gulp.src('foo/*'), gulp.src('bar/*') ) .pipe(concat('result.txt')) .pipe(gulp.dest('build')); }); // ... or ... gulp.task('default', function () { var stream = streamqueue({ objectMode: true }); stream.queue(gulp.src('foo/*')); stream.queue(gulp.src('bar/*')); return stream.done() .pipe(concat('result.txt')) .pipe(gulp.dest('build')); });
Reacted by strohhut and Павел БогатырёвOk cool it works now thanks!
I was wondering, I think the trick here is I need to buffer the first stream, and then append the data from the second stream to the buffer, how might I do that if were not to use any other libraries?
Closing this since it seems like the problem is solved
Thanks @darsain working great!
+1 for objectMode, that's critical!
Metadata
Metadata
Assignees
Labels
No labels
Hi!
I'm still getting used to gulp's processing model and it's not entirely clear to me how to achieve something like this:
The recipe here results in an unordered stream, but I'd like concat to be really concat and not just merge chucks arbitrarily.
Thanks!