基本上我有一组文件,我使用markdown处理,什么不是。在进行初始处理之后,我想将流分成两部分:
将流保存到变量中只是保持管道可以吗?这是我目前的任务:
gulp.task('default', function() {
var entries = gulp.src('./log/*.md')
.pipe(frontMatter())
.pipe(markdown());
var templated = entries
.pipe(applyTemplate())
.pipe(gulp.dest('./build/log'));
var index = entries
.pipe(index())
.pipe(applyIndexTemplate())
.pipe(gulp.dest('./build'));
return merge(templated, index);
}
我可以使用lazypipe和/或只是多次构建管道,但还有另一种方法吗?
答案 0 :(得分:8)
根据Node.js docs,"可以安全地管道多个目的地"原来的例子是正确的:
var entries = gulp.src('./log/*.md')
.pipe(frontMatter())
.pipe(markdown());
var templated = entries
.pipe(applyTemplate())
.pipe(gulp.dest('./build/log'));
var index = entries
.pipe(index())
.pipe(applyIndexTemplate())
.pipe(gulp.dest('./build'));
return merge(templated, index);
答案 1 :(得分:0)
var gulpClone = require("gulp-clone");
var eventStream = require('event-stream');
var entries = gulp.src('./log/*.md')
.pipe(frontMatter())
.pipe(markdown());
var templated = entries
.pipe(gulpClone())
.pipe(applyTemplate())
.pipe(gulp.dest('./build/log'));
var index = entries
.pipe(gulpClone())
.pipe(index())
.pipe(applyIndexTemplate())
.pipe(gulp.dest('./build'));
return eventStream.merge(templated, index);