function rescanDirectoryForDelta
rescanDirectoryForDelta(
watchPath: string,
config: Config,
extensions: string[],
onEventFunc: (
event: string,
file: string
) => unknown
,
onFinishFunc: ((
path: string,
event: string
) => void) | null | undefined
,
trackSymlinkFn?: (filePath: string) => void,
deps?: RescanDeps
): Promise<void>

Scans watchPath recursively and fires add / change / unlink events for any delta between the directory contents and config.fsTree. Used as a 1 s safety-net poll on macOS where FSEvents can drop events under load — additions and removals are recovered from the directory listing, and modifications are recovered by re-stat'ing every tracked file and firing change whenever its mtime is newer than config.state.watch.lastBuildEndMs (the moment the last build saw the file). The seed for that baseline is set in setup.

import * as FileWatcher from './file-watcher.ts';

import type { Config } from '../types.ts';

// Defined, not invoked: walks the real directory tree.
function rescan(config: Config, onEvent: (event: string, file: string) => unknown) {
  return FileWatcher.rescanDirectoryForDelta('/proj/test', config, ['js', 'ts'], onEvent, null);
}

Parameters

watchPath: string
config: Config
extensions: string[]
onEventFunc: (
event: string,
file: string
) => unknown
onFinishFunc: ((
path: string,
event: string
) => void) | null | undefined
optional
trackSymlinkFn: (filePath: string) => void
optional
deps: RescanDeps

Return Type

Promise<void>

Usage

import { rescanDirectoryForDelta } from "lib/setup/file-watcher.ts";