All files / infrastructure/scripts/src/coverage-report/domain discover.ts

100% Statements 8/8
100% Branches 2/2
100% Functions 3/3
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 22 23 24 25 26 27 28 29 30                            1x 3x 3x 1x       2x     1x 3x        
import { join } from "node:path";
import { ExpectedError } from "../../shared/errors.ts";
 
export interface ProjectTarget {
    name: string;
    root: string;
    outputs: string[];
}
 
interface ProjectReport {
    name: string;
    coverageFinal: string;
}
 
const resolveOutput = (name: string, root: string, outputs: string[]): string => {
    const [output] = outputs;
    if (!output) {
        throw new ExpectedError(
            `${name}'s test:coverage declares no output in nx.json — nothing to merge.`,
        );
    }
    return output.replace("{projectRoot}", root);
};
 
export const toReports = (projects: ProjectTarget[]): ProjectReport[] =>
    projects.map(({ name, root, outputs }) => ({
        name,
        coverageFinal: join(resolveOutput(name, root, outputs), "coverage-final.json"),
    }));