I want the gulp calls below to run synchronously, one after the other. But they do not follow an order.
The run-sequence node module doesn't help here, as I'm not trying to run gulp tasks in series (i.e. it has syntax similar to gulp.task("mytask", ["foo", "bar", "baz"]
etc.), but rather gulp "calls" in series, as you see below.
gulp.task("dostuff", function (callback) {
gulp
.src("...")
.pipe(gulp.dest("...");
gulp
.src("...")
.pipe(gulp.dest("...");
gulp
.src("...")
.pipe(gulp.dest("...");
callback();
});
How do I make them run one after the other?
Well, it's just streams so you could listen for the end event (Watch out for the pyramid of doom!)
But it's probably a better pattern to split it up in multiple tasks each one with a dependency on the previous one.
You can use async as a control flow for your calls to get them in only one task, also avoiding you to get a "pyramid effect". So something like this should be good for your use-case:
That will also allow you to have some error handling and target better where a problem occured.
run-sequence:
npm install --save-dev run-sequence
https://www.npmjs.com/package/run-sequence
Use synchronous mode for glob
Then return the result of gulp.src:
you can add something like this after the last pipe