当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript chokidar.FSWatcher类代码示例

本文整理汇总了TypeScript中chokidar.FSWatcher的典型用法代码示例。如果您正苦于以下问题:TypeScript FSWatcher类的具体用法?TypeScript FSWatcher怎么用?TypeScript FSWatcher使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了FSWatcher类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: init

 public async init(): Promise<FSWatcher> {
   try {
     logger.info('Starting watcher');
     return this.fswatcher.on('add', this.onAdd.bind(this));
   } catch (err) {
     logger.error(err);
     throw err;
   }
 }
开发者ID:mshick,项目名称:arrivals-osx,代码行数:9,代码来源:fileWatcher.ts

示例2: constructor

 public constructor(
   private serializer: Serializer,
   private path: string,
   private extension: string,
   watcher?: FSWatcher
 ) {
   super();
   if (watcher) {
     watcher
       .on('add',    filePath => this.onFileUpdated(filePath))
       .on('change', filePath => this.onFileUpdated(filePath))
       .on('unlink', filePath => this.onFileRemoved(filePath))
       .add(path);
   }
 }
开发者ID:samizdatjs,项目名称:tashmetu-fs,代码行数:15,代码来源:directory.ts

示例3: it

it('watch()', () => {
    let watcher: FSWatcher;

    return fs.watch(tmpDir).then(watcher_ => {
        watcher = watcher_;

        return new Promise((resolve, reject) => {
            const path = join(tmpDir, 'test.txt');

            watcher.on('add', (path_) => {
                path_.should.eql(path);
                resolve();
            });

            fs.writeFile(path, 'test').catch(reject);
        });
    }).finally(() => {
        if (watcher) watcher.close();
    });
});
开发者ID:ErikSchierboom,项目名称:DefinitelyTyped,代码行数:20,代码来源:hexo-fs-tests.ts

示例4: constructor

 public constructor(watcher: FSWatcher) {
   watcher
     .on('add',    path => log(chalk.cyan('ADD ') + path))
     .on('change', path => log(chalk.cyan('CHG ') + path))
     .on('unlink', path => log(chalk.cyan('REM ') + path));
 }
开发者ID:samizdatjs,项目名称:tashmetu-fs,代码行数:6,代码来源:reporter.ts

示例5: Promise

        return new Promise((resolve, reject) => {
            const path = join(tmpDir, 'test.txt');

            watcher.on('add', (path_) => {
                path_.should.eql(path);
                resolve();
            });

            fs.writeFile(path, 'test').catch(reject);
        });
开发者ID:ErikSchierboom,项目名称:DefinitelyTyped,代码行数:10,代码来源:hexo-fs-tests.ts

示例6:

 }).finally(() => {
     if (watcher) watcher.close();
 });
开发者ID:ErikSchierboom,项目名称:DefinitelyTyped,代码行数:3,代码来源:hexo-fs-tests.ts


注:本文中的chokidar.FSWatcher类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。