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

91.66% Statements 11/12
100% Branches 2/2
66.66% Functions 2/3
90.9% Lines 10/11

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 22 23 24 25 26 27            1x 3x 3x 3x   2x       1x 3x   2x   2x       1x    
import { createRequire } from "node:module";
import process from "node:process";
import { inherit } from "../../shared/adapters/exec.ts";
import { repoRoot } from "../../shared/adapters/git.ts";
 
/** Resolve the dependency with Node's lookup; a directory check can pass while the import fails. */
const isInstalled = (): boolean => {
    try {
        createRequire(import.meta.url).resolve("@clack/prompts");
        return true;
    } catch {
        return false;
    }
};
 
export const ensureInstalled = (): boolean => {
    if (isInstalled()) return true;
 
    process.stdout.write("No dependencies installed yet — running pnpm install first.\n");
 
    return inherit("pnpm", ["-C", repoRoot(), "install"]) === 0;
};
 
/** Nx supplies `name`, so it is not untrusted flag text. */
export const dev = (name: string): number | null =>
    inherit("pnpm", ["--filter", name, "run", "dev"]);