?yb? 2014-04-02 22:45 采纳率: 100%
浏览 658

如何按顺序一个接一个地运行 Gulp 任务

in the snippet like this:

gulp.task "coffee", ->
    gulp.src("src/server/**/*.coffee")
        .pipe(coffee {bare: true}).on("error",gutil.log)
        .pipe(gulp.dest "bin")

gulp.task "clean",->
    gulp.src("bin", {read:false})
        .pipe clean
            force:true

gulp.task 'develop',['clean','coffee'], ->
    console.log "run something else"

In develop task I want to run clean and after it's done, run coffee and when that's done, run something else. But I can't figure that out. This piece doesn't work. Please advise.

转载于:https://stackoverflow.com/questions/22824546/how-to-run-gulp-tasks-sequentially-one-after-the-other

  • 写回答

11条回答 默认 最新

  • hurriedly% 2014-10-15 19:29
    关注

    The only good solution to this problem can be found in the gulp documentation which can be found here

    var gulp = require('gulp');
    
    // takes in a callback so the engine knows when it'll be done
    gulp.task('one', function(cb) {
      // do stuff -- async or otherwise
      cb(err); // if err is not null and not undefined, the orchestration will stop, and 'two' will not run
    });
    
    // identifies a dependent task must be complete before this one begins
    gulp.task('two', ['one'], function() {
      // task 'one' is done now
    });
    
    gulp.task('default', ['one', 'two']);
    // alternatively: gulp.task('default', ['two']);
    
    评论

报告相同问题?

悬赏问题

  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿