How to run multiple node streams (generated by gulp) sequentially?
Let's assume a simple gulpfile with two depending tasks:
var gulp = require("gulp");
gulp.task("do1", function() {
return gulp.src("./test/*")
.pipe(gulp.dest("./dest/"));
});
gulp.task("do2", function() {
return gulp.src("./dest/*")
.pipe(gulp.dest("./final/"));
});
gulp.task("default", gulp.series("do1", "do2"));
What I came up with so far:
var gulp = require("gulp");
function do1() {
return gulp.src("./test/*")
.pipe(gulp.dest("./dest/"));
}
function do2() {
return gulp.src("./dest/*")
.pipe(gulp.dest("./final/"));
}
gulp.task("do1", function() {
return do1();
});
gulp.task("do2", function() {
return do2();
});
gulp.task("default", gulp.series("do1", "do2"));
// ...
// somewhere else in the same file, with some preconditions ...
do1().on("finish", do2);
Indeed this is working for this simple example, but is there a more convenient / elegant way? In particular for longer dependency chains. Maybe a solution using gulp.series
and execute the whole series?