UNPKG

jgb-cli

Version:

```shell npm i -g jgb-cli #全局安装 ```

43 lines (42 loc) 1.28 kB
import { FSWatcher } from 'chokidar'; /** * This watcher wraps chokidar so that we watch directories rather than individual files on macOS. * This prevents us from hitting EMFILE errors when running out of file descriptors. * Chokidar does not have support for watching directories on non-macOS platforms, so we disable * this behavior in order to prevent watching more individual files than necessary (e.g. node_modules). */ export default class Watcher { shouldWatchDirs: boolean; watcher: FSWatcher; watchedDirectories: Map<any, any>; stopped: boolean; constructor(); /** * Find a parent directory of `path` which is already watched */ getWatchedParent(path: string): string; /** * Find a list of child directories of `path` which are already watched */ getWatchedChildren(path: string): any[]; /** * Add a path to the watcher */ watch(path: string): void; /** * Remove a path from the watcher */ unwatch(path: string): void; /** * Add an event handler */ on(event: string, callback: () => any): void; /** * Add an event handler */ once(event: string, callback: () => any): void; /** * Stop watching all paths */ stop(): void; }