From 57934df9848f0e211d38e39a1438bff0da7c2dba Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Mon, 16 Jan 2023 23:06:59 +0100 Subject: [PATCH] repo-tools: fix warning counter for non-index API reports Signed-off-by: Patrik Oldsberg --- .../src/commands/api-reports/api-extractor.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/repo-tools/src/commands/api-reports/api-extractor.ts b/packages/repo-tools/src/commands/api-reports/api-extractor.ts index 91df053f22..c05fd0a01e 100644 --- a/packages/repo-tools/src/commands/api-reports/api-extractor.ts +++ b/packages/repo-tools/src/commands/api-reports/api-extractor.ts @@ -237,10 +237,9 @@ export async function createTemporaryTsConfig(includedPackageDirs: string[]) { return path; } -export async function countApiReportWarnings(projectFolder: string) { - const path = resolvePath(projectFolder, 'api-report.md'); +export async function countApiReportWarnings(reportPath: string) { try { - const content = await fs.readFile(path, 'utf8'); + const content = await fs.readFile(reportPath, 'utf8'); const lines = content.split('\n'); const lineWarnings = lines.filter(line => @@ -380,9 +379,12 @@ export async function runApiExtraction({ packageDir, ); - const warningCountBefore = await countApiReportWarnings(projectFolder); - const prefix = name === 'index' ? '' : `${name}-`; + const reportFileName = `${prefix}api-report.md`; + const reportPath = resolvePath(projectFolder, reportFileName); + + const warningCountBefore = await countApiReportWarnings(reportPath); + const extractorConfig = ExtractorConfig.prepare({ configObject: { mainEntryPointFilePath: resolvePath(packageFolder, `src/${name}.d.ts`), @@ -394,7 +396,7 @@ export async function runApiExtraction({ apiReport: { enabled: true, - reportFileName: `${prefix}api-report.md`, + reportFileName, reportFolder: projectFolder, reportTempFolder: resolvePath( outputDir, @@ -547,7 +549,7 @@ export async function runApiExtraction({ ); } - const warningCountAfter = await countApiReportWarnings(projectFolder); + const warningCountAfter = await countApiReportWarnings(reportPath); if (noBail) { console.log(`Skipping warnings check for ${packageDir}`); }