吞咽过程任务的顺序是什么? [英] In what order does gulp process tasks?

查看:146
本文介绍了吞咽过程任务的顺序是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对使用Gulp完成任务的顺序感到困惑。请允许我解释一下。



在gulpfile.js中,我拥有所有必需的依赖关系,后跟一组任务。



每个子任务的基本模板是

pre $ g $ p $ gulp.task('compress:customName',function(){
return gulp.src(['app / folder / file.js','app / folder / file.js'])
.pipe(gp_concat('app.customName.min.js'))
.pipe(gp_uglify())
.pipe(gulp.dest(distDir));
});

然后,我有一项任务规定它们全部

  gulp.task('compress:all',[
'compress:customName1',
'compress:customName2',
'etc ...'
],function(){});

然后再添加一个主任务运行者(仅使用compress:全部用于此示例) b
$ b

  gulp.task('master',['compress:all'],function(){
return gulp.src('dist /*.js')
.pipe(notify(COMPRESSION COMPLETE));
});

好的......这是基本的设置......现在来说说这些任务的顺序看起来是完成每个命令行的结果。

  [11:06:44]使用gulpfile C:\PATH\ TO \PROJECT\gulpfile.js 
[11:06:44]开始'compress:customName1'...
[11:06:44]开始'compress:customName2'...
[11:06:44]开始压缩:customName3'...
[11:06:44]开始压缩:customName4'...
[11:06:44]开始'compress:customName5'...
[11:06:44]开始'compress:customName6'...
[11:06:44]开始'compress:customName7'...
[11:06:44] 108 ms后完成'compress:customName1'
[11:06:44] 93 ms后完成'compress:customName6'
[11:06:44]在132 ms后完成'compress:customName5'
[11:06:44] 139 ms后完成'compress:customName4'
[11:06:44] 233 ms后完成'compress:customName3'
[11:06:44] Fin在245 ms之后,压缩:customName2'
[11:06:44] 381 ms后完成'compress:customName7'
[11:06:44]开始压缩:所有'...
[11:06:44]完成'compress:all'6.64 s后
[11:06:44]启动'master'...
[11:06:44] gulp-通知:[例如:Gulp Builder] COMPRESSION COMPLETE
[11:06:44] 40 ms后完成'master'

为什么'master'是最后一个启动并开始后的任务'compress:all'?



为什么完成的任务显示在这样的随机顺序?



为什么说'master'只有40毫秒才能完成,因为它应该等待它调用的所有子任务,然后再考虑完成

解决方案


'master'是最后一个启动和启动后的任务'compress'所有'?


在实际任务开始之前运行依赖关系。 'compress:all'是依赖于'master'。


为什么Finished任务以这样的随机顺序显示?


依赖关系并行运行,也就是完成一次只取决于完成一次所需的时间。


为什么说'master'只有40毫秒才能完成,当它应该等待它所调用的所有子任务,然后再考虑自己的完成?


任务完成时间内不包含依赖项。




deps - 在您的任务运行之前要执行并完成的任务数组。
$ b

< a href =https://github.com/gulpjs/gulp/blob/master/docs/API.md#deps =nofollow> https://github.com/gulpjs/gulp/blob/master/ docs / API.md#deps


I'm a bit confused about the order in which tasks are completed using Gulp. Allow me to explain.

In gulpfile.js, I have all my required dependencies followed by a set of tasks.

The basic template of each sub task is

gulp.task('compress:customName', function() {
    return gulp.src(['app/folder/file.js', 'app/folder/file.js'])
        .pipe(gp_concat('app.customName.min.js'))
        .pipe(gp_uglify())
        .pipe(gulp.dest(distDir));
});

Then, I have a task that rules them all

gulp.task('compress:all', [
    'compress:customName1', 
    'compress:customName2', 
    'etc...'
], function() {});

Then one more master task runner (just using compress:all for this example)

gulp.task('master', ['compress:all'], function() {
    return gulp.src('dist/*.js')
        .pipe(notify("COMPRESSION COMPLETE"));
});

OK...that's the basic setup...now to talk about the order in which these tasks appear to be completed per the command line results.

[11:06:44] Using gulpfile C:\PATH\TO\PROJECT\gulpfile.js
[11:06:44] Starting 'compress:customName1'...
[11:06:44] Starting 'compress:customName2'...
[11:06:44] Starting 'compress:customName3'...
[11:06:44] Starting 'compress:customName4'...
[11:06:44] Starting 'compress:customName5'...
[11:06:44] Starting 'compress:customName6'...
[11:06:44] Starting 'compress:customName7'...
[11:06:44] Finished 'compress:customName1' after 108 ms
[11:06:44] Finished 'compress:customName6' after 93 ms
[11:06:44] Finished 'compress:customName5' after 132 ms
[11:06:44] Finished 'compress:customName4' after 139 ms
[11:06:44] Finished 'compress:customName3' after 233 ms
[11:06:44] Finished 'compress:customName2' after 245 ms
[11:06:44] Finished 'compress:customName7' after 381 ms
[11:06:44] Starting 'compress:all'...
[11:06:44] Finished 'compress:all' after 6.64 µs
[11:06:44] Starting 'master'...
[11:06:44] gulp-notify: [SO EXAMPLE : Gulp Builder] COMPRESSION COMPLETE
[11:06:44] Finished 'master' after 40 ms

How can 'master' be the last task to start and starts AFTER 'compress:all'?

Why are the Finished tasks displaying in such a random order?

Why is it that 'master' is said to have completed in only 40 ms when it should be waiting for all the sub-tasks it invokes to respond before considering itself complete?

解决方案

How can 'master' be the last task to start and starts AFTER 'compress:all'?

Dependencies are run before actual task is started. 'compress:all' is dependency for 'master'.

Why are the Finished tasks displaying in such a random order?

Dependencies are run in parallel i.e. when one finishes depends only on the time it takes to complete one.

Why is it that 'master' is said to have completed in only 40 ms when it should be waiting for all the sub-tasks it invokes to respond before considering itself complete?

Dependencies are not included in the completion time of a task.


"deps – An array of tasks to be executed and completed before your task will run."

https://github.com/gulpjs/gulp/blob/master/docs/API.md#deps

这篇关于吞咽过程任务的顺序是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆