javascript - How to return all the streams at once from a gulp task with multiple source files? -
the gulp task wrote breaks runsequence in main gulp task. has run in between other tasks, this:
runsequence( ... ':build:prod:staticindex', ':build:prod:typedoctomd', // << task ':build:prod:staticdocumentation', ...etc
and task after never gets executed. makes me think task doesn't return single stream or incorrectly.
here how task looks:
gulp.task(':build:prod:typedoctomd', (done: any) => { let tasknum: number = 0; let streams = []; let filespath = [ path.join(__config.tmpl_docs_path, '**/*.md') ]; glob(filespath.tostring(), function (er, files) { tasknum = files.length - 1; files.foreach((filename) => { let stream = gulp.src(filename) .pipe(addtypedoc()) // << custom plugin wrote .pipe(gulp.dest(function (file) { return file.base; })); stream.on('end', () => { streams.push(stream); if (streams.length === tasknum) { gutil.log('the end!'); return merge(streams); } }); }); }); });
so used glob recursively md files folder. , used merge-stream combine streams , return single one.
i 'the end!' message logged gulp never gets next task after that.
am missing here?
thanks in advance help!
ok, found solution this, , it's ridiculously simple: use task's callback argument this:
if (streams.length === tasknum) { gutil.log('the end!'); done(); }
now works! , didn't have use merge-stream after all.
Comments
Post a Comment