TypeScript watch watchTree示例

说明

typescript watch watchtree示例是从最受好评的开源项目中提取的实现代码,你可以参考下面示例的使用方式。

编程语言: TypeScript

命名空间/包名称: watch

示例#1
文件: livereload.ts 项目: simonxca/dungeon-crawler-v2

module.exports = function (app: express.Express) {
  app.use(livereload);
  watch.watchTree(`${config.root}/public/`, {
    ignoreDirectoryPattern: /(public[/\\]ts)|public[/\\]scss/
  }, () => {
    livereload.broadcast({action: 'reload'});
  });
};

示例#2
文件: build-html.ts 项目: alsatian-test/alsatian-website

    Object.keys(mappingConfig.assetsByChunkName)
    .forEach(key => {
        const remappedName = mappingConfig.assetsByChunkName[key];

        // if the remapped name is a string then just asign it
        if (typeof remappedName === "string") {
            mapping[key] = remappedName; 
        }
        // otherwise it's an array so 
        else {            
            mapping[key] = remappedName[0]; 
        }
    });

    return mapping;
}

buildWebAppHtml();

// if we were told to watch
if (process.argv.indexOf("--watch") !== -1) {

    // check out the cache busting maps and rebuild when they change
    Watch.watchTree(cacheMappingPath,
    {
        filter: (path: string) => {
            return !/\.html$/.test(path);
        }
    },
    buildWebAppHtml);
}

展开阅读全文