gulp.run
and gulp.start
are considered bad practice:
https://github.com/gulpjs/gulp/issues/426
https://github.com/gulpjs/gulp/issues/505
Unfortunately, the answer here appears to be that your coworker may not really understand Gulp. You may not be able to fix this problem without changing their code.
Without more context, like the entire gulpfile, I can't reproduce your exact problem. However, my hunch is that it has something to do with the way that Gulp runs tasks asynchronously/continuously. It may be the case that your 'default' task is exiting prematurely, because gulp.run
does not execute synchronously. One way or another, Gulp is confused about which tasks need to wait on what, when. You're using two completely different tools to manage your run-sequence.
Instead of gulp.run
, your 'serve' task should really use dependencies to run other tasks:
gulp.task('serve', ['fonts', 'browsersync', 'watch']);
gulp.task('default', ['serve']);
Also, it is worth pointing out that your watch task is already listing 'browsersync' as a dependency. While not technically incorrect (Gulp will ignore it the second time), it can lead to overcomplication and confusion and so probably isn't a good idea. If 'watch' depends on 'browsersync', you can just remove the 'browsersync' dependency from 'serve':
gulp.task('watch', ['styles', 'browsersync'], function () {
gulp.watch([
'./app/assets/sass/**/*.scss',
'./app/modules/**/*.scss'
], ['styles']);
gulp.watch([
'./app/**/*.js',
'./app/**/*.html'
], function() {
reload();
});
});
gulp.task('serve', ['fonts', 'watch']);
gulp.task('default', ['serve']);
This should get you the result you're looking for.
All that being said, if you really insist on following bad practice, you might try using gulp.run
in your 'default' task:
gulp.task('default', function() {
gulp.run('serve');
});
I suspect your main problem is that you are mixing the usage of array task dependencies and gulp.run
, but either way, gulp.run
is "doing it wrong".