I am trying to run through a list of file names, move the file and zip them, then delete the file in gulp. I keep running into the issue that the next task is started before the previous task is finished.
function moveFiles(cb) {
folders.forEach(function(item,index){
    var _tmp = '../final_files/' + item;
      return Promise.all([
        new Promise(function(resolve, reject) {
           gulp.src('../' + item + '/**/*').pipe(gulp.dest(_tmp))
            .on('end', resolve)
        }),
        new Promise(function(resolve, reject) {
             gulp.src('../master/assets/**/*.*').pipe(gulp.dest(_tmp + '/assets/'))
            .on('end', resolve)
        }),
        new Promise(function(resolve, reject) {
             gulp.src([_tmp + '/**', _tmp + '/style/**', _tmp + '/js/**'], {base: "./"})
                .pipe(replace('../master/assets', 'assets'))
                .pipe(gulp.dest('.'))   
                .on('end', resolve)   
        }), 
        new Promise(function(resolve, reject) {
            return gulp.src(_tmp + '/**/*.*')
                .pipe(zip(item + '.zip'))
                .pipe(gulp.dest( '../final_files/'))
                .on('end', resolve) 
        }),         
      ]).then(function () {
         return gulp.src(_tmp, {read: false}).pipe(clean({force: true}));                   
      });       
});
}
I've tried to break it out into task, but I can't figure out how to pass a parameter to a task, or have the task wait for it to finish. Any direction would be greatly appreciated.
Regards
