function getChangedFsTree
getChangedFsTree(
fsTree: FSTree,
config: Config,
changedSince: string,
): Promise<FSTree>

Returns a new fsTree containing only the test files affected by changes since ref, per the cached esbuild metafile's reverse-dependency graph.

Falls back to returning the input fsTree unchanged (with a notice) when any of these hold — they are "run-all is the safe answer" scenarios, not bugs:

  • blast-radius file changed (package.json, tsconfig.json, …): full graph potentially affected, dep walk would miss it.
  • no metafile cache yet: nothing built before this run.
  • git failed: not a repo, ref doesn't exist, git binary missing.

Always announces how the filter resolved (full / filtered / fallback) so users can reason about why their selected suite ran.

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

// Defined, not invoked: reads the metafile cache and runs git.
async function narrow(fsTree: FSTree, config: Config) {
  return getChangedFsTree(fsTree, config, 'HEAD'); // only tests affected since HEAD
}

Parameters

fsTree: FSTree
config: Config
changedSince: string
optional
getChanged: getChangedFilePathsInGitSince = getChangedFilePathsInGitSince

Return Type

Promise<FSTree>

Usage

import { getChangedFsTree } from "lib/setup/get-changed-fs-tree.ts";