并排使用'gulp.watch'和'tsc -watch'

问题描述

我可以弄清楚为什么gulp.watch()后面似乎只有tsc -watch可以工作一半。同一文件上不能有多个观察者?或者,还有其他事情吗?

import { TaskFunction } from 'gulp';
import { spawn } from 'child_process';
import theMetask from './theme';
import { watch } from 'gulp';

const task: TaskFunction = (done: CallableFunction): void => {
    watch('./src/themes/*.json',theMetask);

    // This watcher is seems to be ignored whenever 'tsc' is spawned.
    watch('./src/colors.ts',{ useFsEvents: true },(done: CallableFunction): void => {
        spawn('npm',['run','build:theme'],{
            stdio: 'inherit'
        })
        .on('exit',() => done());
    });

    spawn('tsc',[
        './src/extension.ts','--outDir','./dist','--listemittedFiles','-watch','--preserveWatchOutput'
    ],{
        stdio: 'inherit'
    });

    done();
};

export default task;

更新1

也许我没有正确发信号Async Completion?这是我更新的代码。有人可以确认这是原因吗?

import { TaskFunction } from 'gulp';
import theMetask from './theme';
import { watch } from 'gulp';
import { ChildProcess,spawn } from 'child_process';

// Removed completion since the task doesn't factually complete.
const task: TaskFunction = (): void => {
    watch('./src/themes/*.json',theMetask);

    // Changed completion to ChildProcess.
    watch('./src/colors.ts',(): ChildProcess => {
        return spawn('npm',{
            stdio: 'inherit'
        });
    });

    spawn('tsc',{
        stdio: 'inherit'
    });
};

export default task;

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)