首页 > 解决方案 > 并行运行两个 gulp.watch 任务

问题描述

我在运行两个单独的 gulp 手表作为我的默认任务时遇到了麻烦。这是我的 gulpfile.babel.js

import gulp from "gulp";
import git from "gulp-git";
import ts from "gulp-typescript";

const tsProject = ts.createProject("tsconfig.json");

export function watchTs() {
  gulp.watch(
    // details omitted...
  );
}

export function watchGit() {
  gulp.watch(
   // details omitted...
  );
}

export default function(cb) {
  gulp.parallel(watchTs, watchGit);
}

这就是我运行 gulp 时发生的情况:

master* $ gulp                                                                [16:21:52]
[16:21:54] Requiring external module @babel/register
[16:21:55] Using gulpfile ~/Documents/github/screeps/gulpfile.babel.js
[16:21:55] Starting 'default'...
[16:21:55] The following tasks did not complete: default
[16:21:55] Did you forget to signal async completion?

我可以通过运行得到正确的结果:gulp watchTs & gulp watchGit。为什么这不起作用?

标签: javascriptnode.jsgittypescriptgulp

解决方案


我想到了。我认为默认值需要是我定义的函数,但这有效。

export default gulp.parallel(watchTs, watchGit);

我仍然不能 100% 确定为什么其他方法不起作用。欢迎任何有助于我理解的反馈。


推荐阅读