All files / infrastructure/scripts/src/dev/adapters nx.ts

100% Statements 9/9
100% Branches 0/0
100% Functions 5/5
100% Lines 7/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21          1x     3x   1x 3x         1x 1x 3x    
import { run } from "../../shared/adapters/exec.ts";
import { at } from "../../shared/adapters/git.ts";
import { PROJECT_ROOTS } from "../../shared/domain/layout.ts";
import type { Runnable } from "../domain/projects.ts";
 
const TARGET = "dev";
 
/** Resolve Nx from the repo install because this script may run immediately after installing it. */
const nx = (): string => at("node_modules", ".bin", "nx");
 
const show = (...args: string[]): string[] =>
    JSON.parse(
        run(nx(), ["show", "projects", "--with-target", TARGET, "--json", ...args]),
    ) as string[];
 
/** Query Nx by project root so project names need not match directory names. */
export const projectsWithDev = (): Runnable[] =>
    PROJECT_ROOTS.flatMap((root) =>
        show("--projects", `${root}/*`).map((name) => ({ root, name })),
    );