I am aware of the ability to declare dependencies that will run before the task, e.g.
gulp.task('a', () => {}); gulp.task('b', () => {}); gulp.task('c', ['a', 'c'], () => {});
Tasks 'a' and 'b' will be run every time after task 'c' is called and before task 'c' is executed.
However, how do I programmatically call an arbitrary task from within a gulp.task
?
in the Before launch area and choose Run Gulp task from the list. In the Gulp task dialog that opens, specify the Gulpfile. js where the required task is defined, select the task to execute, and specify the arguments to pass to the Gulp tool. Specify the location of the Node.
To have your tasks execute in order, use the series() method. For tasks to run at maximum concurrency, combine them with the parallel() method. Tasks are composed immediately when either series() or parallel() is called. This allows variation in the composition instead of conditional behavior inside individual tasks.
To indicate to gulp that an error occurred in a task using an error-first callback, call it with an Error as the only argument. However, you'll often pass this callback to another API instead of calling it yourself.
A gulpfile is a file in your project directory titled gulpfile. js (or capitalized as Gulpfile. js , like Makefile), that automatically loads when you run the gulp command.
I did it using gulp.start(); like this:
gulp.task('test1', function(){ gulp.start('test2'); }) gulp.task('test2', function(){ // do something })
I was using gulp 3.9.1 if it matters. Looks like gulp.start() may be removed or deprecated; but it hasn't happened yet.
Update If I were to break things out into separate functions, as Novellizator suggested, it would be something like this:
function doSomething(){ // do something } gulp.task('test1', function(){ doSomething(); }) gulp.task('test2', function(){ doSomething(); })
It is simple and avoids the use of gulp.start().
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With