1 |
|
2 |
|
3 |
|
4 |
|
5 | import fs = require("fs");
|
6 | import events = require("events");
|
7 |
|
8 | export interface Files {
|
9 | [key: string]: fs.Stats;
|
10 | }
|
11 |
|
12 | export interface Monitor extends events.EventEmitter {
|
13 | files: Files;
|
14 |
|
15 | on(event: "created" | "removed", listener: (f: string, stat: fs.Stats) => void): this;
|
16 | on(event: "changed", listener: (f: string, current: fs.Stats, prev: fs.Stats) => void): this;
|
17 | on(event: string, listener: (...args: any[]) => void): this;
|
18 | stop(): void;
|
19 | }
|
20 |
|
21 | export interface BaseOptions {
|
22 | ignoreDotFiles?: boolean | undefined;
|
23 | filter?(path: string, stat: fs.Stats): boolean;
|
24 | }
|
25 |
|
26 | export interface Options extends BaseOptions {
|
27 | interval?: number | undefined;
|
28 | }
|
29 |
|
30 | export interface WalkOptions extends BaseOptions {
|
31 | ignoreUnreadableDir?: boolean | undefined;
|
32 | ignoreNotPermitted?: boolean | undefined;
|
33 | ignoreDirectoryPattern?: RegExp | undefined;
|
34 | }
|
35 |
|
36 | export function watchTree(root: string, callback: (f: string, curr: fs.Stats, prev: fs.Stats) => void): void;
|
37 | export function watchTree(
|
38 | root: string,
|
39 | options: Options,
|
40 | callback: (f: string, curr: fs.Stats, prev: fs.Stats) => void,
|
41 | ): void;
|
42 | export function unwatchTree(root: string): void;
|
43 | export function createMonitor(root: string, callback: (monitor: Monitor) => void): void;
|
44 | export function createMonitor(root: string, options: Options, callback: (monitor: Monitor) => void): void;
|
45 | export function walk(root: string, callback: (error: Error | null, files: Files | undefined) => void): void;
|
46 | export function walk(
|
47 | root: string,
|
48 | options: WalkOptions,
|
49 | callback: (error: Error | null, files: Files | undefined) => void,
|
50 | ): void;
|