我需要建立的咕嘟咕嘟的任务,像这样的顺序:
任务1 - > Task2A,Task2B,Task2C - >任务3,
其中任务2A,2B,2C并行运行(但task1应该在之前完成,并且只完成一次)。
我尝试过:
gulp.task('Task1',[]); gulp.task('Task2A',['Task1']); gulp.task('Task2B',['Task1']); gulp.task('Task2C',['Task1']); gulp.task('Task3',['Task2A','Task2B','Task2C']);看起来像是在工作,但我不确定,它是否保证只会执行Task1 1次,或者它可以被触发多次?
谢谢。
解决方案也许最简单的方法(不使用gulp4.0)是 run-序列插件。
您的情况:
var runSequence = require('run-sequence'); gulp.task('build',function(callback){ runSequence('Task1', ['Task2A','Task2B','Task2C'],'Task3',回调); });确保您的所有任务都有返回语句。
请注意
这是一个临时解决方案,直到发布gulp 4.0应该支持定义任务
考虑到Gulp 4似乎永远不会完全发布,请将其作为您的愿望。请注意,此解决方案是一种破解方式,可能会在将来更新gulp时停止工作。
I need to build a sequence of Gulp tasks like this:
Task1 -> Task2A, Task2B, Task2C -> Task3,
where tasks 2A,2B,2C run in parallel(but task1 should be completed before, and completed just once).
What I tried:
gulp.task('Task1', []); gulp.task('Task2A', ['Task1']); gulp.task('Task2B', ['Task1']); gulp.task('Task2C', ['Task1']); gulp.task('Task3', ['Task2A', 'Task2B', 'Task2C']);Looks like it's working, but I'm not sure, does it guarantee that Task1 will be executed only 1 time, or it can be triggered multiple times?
Thank you.
解决方案Perhaps the simplest way to do this (without using gulp4.0) is the run-sequence plugin.
For your case:
var runSequence = require('run-sequence'); gulp.task('build', function(callback) { runSequence( 'Task1', ['Task2A', 'Task2B', 'Task2C'], 'Task3', callback); });Make sure you have return statements in all your tasks.
Please Note
This was intended to be a temporary solution until the release of gulp 4.0 which should have support for defining task dependencies similarly.
Given that Gulp 4 appears to never be fully released, take that for what you will. Be aware that this solution is a hack, and may stop working with a future update to gulp.
更多推荐
几个Gulp任务等待另一个任务
发布评论