function watchDirectoriesFrom
watchDirectoriesFrom(
inputs: string[],
cwd: string,
pathApi?: Pick<path, "resolve" | "dirname">
): string[]

The directories watch mode should watch, from esbuild's metafile input keys.

esbuild reports inputs relative to absWorkingDir when it can and ABSOLUTELY when it cannot — a script on another Windows drive than the project has no relative form. resolve handles both because an absolute second argument wins outright; the earlier code only ever saw the relative case. node_modules is dropped (a dependency edit is not a script edit) along with esbuild's synthetic <stdin> entry, which is not a file at all.

pathApi is injected so the Windows shape is provable from a POSIX host.

import path from 'node:path';
import { watchDirectoriesFrom } from './run.ts';

watchDirectoriesFrom(['<stdin>', 'scripts/seed.ts'], '/proj', path.posix); // ['/proj/scripts']

Parameters

inputs: string[]
cwd: string
optional
pathApi: Pick<path, "resolve" | "dirname"> = path

Return Type

string[]

Usage

import { watchDirectoriesFrom } from "lib/commands/run.ts";