Skip to content

Commit ea810cd

Browse files
committed
feat: community addition
1 parent 884ad98 commit ea810cd

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

src/github/core.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { limitPreviousReports, stripAnsi } from '../ctrf'
33
import { generateMarkdown } from '../handlebars/core'
44
import { Inputs, CtrfReport } from '../types'
55
import { readTemplate } from '../utils'
6-
import { BuiltInReports } from '../reports/core'
6+
import { BuiltInReports, getBasePath } from '../reports/core'
77
import { COMMUNITY_REPORTS_PATH } from '../config'
88
import { join } from 'path'
99

@@ -96,11 +96,9 @@ export function generateViews(inputs: Inputs, report: CtrfReport): void {
9696
}
9797

9898
if (inputs.communityReport && inputs.communityReportName) {
99+
const basePath = getBasePath(COMMUNITY_REPORTS_PATH)
99100
const customTemplate = readTemplate(
100-
join(
101-
__dirname,
102-
`../${COMMUNITY_REPORTS_PATH}/${inputs.communityReportName}.hbs`
103-
)
101+
join(basePath, `${inputs.communityReportName}.hbs`)
104102
)
105103
const customMarkdown = generateMarkdown(customTemplate, report)
106104
core.summary.addRaw(customMarkdown).addEOL().addEOL()

src/reports/core.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { join } from 'path';
22
import { existsSync } from 'fs';
33

4-
const basePath = getBasePath();
4+
const basePath = getBasePath('reports');
55

66
export const BuiltInReports = {
77
SummaryTable: join(basePath, 'summary-table.hbs'),
@@ -20,14 +20,14 @@ export const BuiltInReports = {
2020
SuiteList: join(basePath, 'suite-list.hbs'),
2121
} as const;
2222

23-
function getBasePath(): string {
23+
export function getBasePath(report: 'reports'| 'community-reports'): string {
2424
const runMode = process.env.RUN_MODE || 'cli';
2525

2626
if (runMode === 'cli') {
2727
return __dirname;
2828
}
2929

30-
const actionPath = join(__dirname, 'reports');
30+
const actionPath = join(__dirname, report);
3131
if (existsSync(actionPath)) {
3232
return actionPath;
3333
}

0 commit comments

Comments
 (0)