MCPcopy Create free account
hub / github.com/code-pushup/cli / loadReport

Function loadReport

packages/utils/src/lib/reports/load-report.ts:17–34  ·  view source on GitHub ↗
(
  options: Required<Omit<PersistConfig, 'format'>> & {
    format: T;
  },
)

Source from the content-addressed store, hash-verified

15type LoadedReportFormat<T extends Format> = T extends 'json' ? Report : string;
16
17export async function loadReport<T extends Format>(
18 options: Required<Omit<PersistConfig, 'format'>> & {
19 format: T;
20 },
21): Promise<LoadedReportFormat<T>> {
22 const { outputDir, filename, format } = options;
23 await ensureDirectoryExists(outputDir);
24 const filePath = path.join(outputDir, `${filename}.${format}`);
25
26 if (format === 'json') {
27 const content = await readJsonFile(filePath);
28 const report: Report = validate(reportSchema, content);
29 return report as LoadedReportFormat<T>;
30 }
31
32 const text: string = await readTextFile(filePath);
33 return text as LoadedReportFormat<T>;
34}

Callers 2

uploadFunction · 0.90

Calls 4

validateFunction · 0.90
readJsonFileFunction · 0.85
readTextFileFunction · 0.85
ensureDirectoryExistsFunction · 0.50

Tested by

no test coverage detected