Answer the question
In order to leave comments, you need to log in
How to give return only after exiting a loop in gulp?
Good afternoon dear experts. There is the following code:
gulp.task('copy-template', function() {
for(var i = 0; i < directory.length; i++) {
gulp.src(directory[i] + '**/*.*')
.pipe(gulp.dest(directory[i] + 'template/'));
}
return true;
});
Answer the question
In order to leave comments, you need to log in
To do this, you can use the merge2 module:
import * as merge2 from 'merge2';
gulp.task('copy-template', ()=>{
let tasks=[];
for(var i = 0; i < directory.length; i++) {
tasks.push(gulp.src(directory[i] + '**/*.*')
.pipe(gulp.dest(directory[i] + 'template/')));
}
return merge2(tasks);
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question