watcher.d.ts 1.1 KB

123456789101112131415161718192021222324252627282930
  1. /// <reference types="node" />
  2. import { FSWatcher, WatchOptions } from 'chokidar';
  3. type FileTransform = (source: Buffer, filename: string) => void | string;
  4. export interface FileWatcherOptions {
  5. src: string | string[];
  6. dest: string;
  7. transform?: FileTransform;
  8. verbose?: boolean;
  9. }
  10. export declare class FileWatcher {
  11. private src;
  12. private dest;
  13. private transform?;
  14. private verbose?;
  15. private watcher;
  16. private onChange?;
  17. constructor({ src, dest, transform, verbose }: FileWatcherOptions);
  18. watch(watchOptions: WatchOptions & {
  19. cwd: string;
  20. }, onReady?: (watcher: FSWatcher) => void, onChange?: () => void): FSWatcher;
  21. add(paths: string | ReadonlyArray<string>): FSWatcher;
  22. unwatch(paths: string | ReadonlyArray<string>): FSWatcher;
  23. close(): Promise<void>;
  24. copy(from: string): Promise<void | undefined>;
  25. remove(from: string): Promise<void | undefined>;
  26. info(type: 'close' | 'copy' | 'remove' | 'add' | 'unwatch', msg?: string | unknown): void;
  27. from(from: string): string;
  28. to(from: string): string;
  29. }
  30. export {};