I use Gulp 4 and I have this task:
gulp.task('deploy', gulp.series('clean', 'handlers:all', 'deployment'));
The task call three other tasks:
- Task
clean
: removes the build folder. - Task
handlers:all
: re-creates the build folder and adds files there. - Task
deployment
: transfers the contents of the build folder to another location
I have a problem with task the deployment
which look something like this:
gulp.task('deployment', done => {
gulp.src('./build/')
.pipe(gulp.dest('../other-project/'));
});
gulp.src() can't find the build folder because it was deleted by the task clean
. When I set the timeout there are no problems. But this solution is bad.
gulp.task('deployment', done => {
setTimeout(() => {
gulp.src('./build/')
.pipe(gulp.dest('../other-project/'));
}, 2000);
});
How do I solve this problem?
Task clean
:
gulp.task('clean', done => {
del('./build/');
done();
});
Task handlers:all
:
gulp.task('handlers:all', gulp.parallel('scripts', 'templates', 'styles', 'fonts', 'favicons', 'images', 'svg', 'dist'));