UNPKG

kist

Version:

Package Pipeline Processor

46 lines (45 loc) 1.65 kB
import { AbstractProcess } from "../core/abstract/AbstractProcess"; /** * LiveWatcher is a utility class for monitoring file and directory changes. * It leverages the `chokidar` library to efficiently detect file changes and * trigger appropriate callbacks. */ export declare class LiveWatcher extends AbstractProcess { /** * The chokidar file watcher instance. */ private watcher; private pathsToWatch; private ignoredPaths; private onChange; /** * Creates an instance of LiveWatcher. * @param pathsToWatch - An array of paths to monitor for changes. * @param ignoredPaths - A regular expression to specify paths or patterns * to exclude from watching. * @param onChange - A callback function that is executed when a file * change is detected. */ constructor(onChange: (filePath: string) => void); /** * Initializes and configures the chokidar watcher to monitor files and * directories. */ private setupWatchers; /** * Starts the file watcher if it is not already running. If the watcher * was stopped previously, it re-initializes the watcher. */ startWatching(): void; /** * Stops the file watcher and releases its resources. This is useful when * you need to clean up or reinitialize the watcher. */ stopWatching(): Promise<void>; /** * Restarts the file watcher by first stopping the existing watcher (if * any) and then starting a new one. This can be useful in scenarios where * watcher configurations or paths have changed. */ restartWatcher(): Promise<void>; }