All files / infrastructure/scripts/src/issue/adapters files.ts

0% Statements 0/12
100% Branches 0/0
0% Functions 0/8
0% Lines 0/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                                             
import { existsSync, readdirSync, readFileSync } from "node:fs";
import { at } from "../../shared/adapters/git.ts";
import { PROJECT_ROOTS } from "../../shared/domain/layout.ts";
import { parseDecision, type Decision } from "../domain/brief.ts";
 
const DECISIONS = "docs/decisions";
 
export const decisions = (): Decision[] =>
    readdirSync(at(DECISIONS))
        .filter((name) => /^\d{4}-.+\.md$/.test(name))
        .map((name) =>
            parseDecision(`${DECISIONS}/${name}`, readFileSync(at(DECISIONS, name), "utf8")),
        );
 
export const projectDirs = (): string[] =>
    PROJECT_ROOTS.flatMap((root) =>
        readdirSync(at(root), { withFileTypes: true })
            .filter((entry) => entry.isDirectory())
            .map(({ name }) => `${root}/${name}`),
    );
 
export const exists = (path: string): boolean => existsSync(at(path));