From 0fc0befe2413381d6cbf075fc980744e28b70895 Mon Sep 17 00:00:00 2001 From: Rob Herley Date: Tue, 1 Mar 2022 21:32:26 -0500 Subject: [PATCH] export markdownSummary singleton from core --- packages/core/src/core.ts | 5 +++++ packages/core/src/markdown-summary.ts | 13 ++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/packages/core/src/core.ts b/packages/core/src/core.ts index fafe3e6cf9..8a9170ca71 100644 --- a/packages/core/src/core.ts +++ b/packages/core/src/core.ts @@ -359,3 +359,8 @@ export function getState(name: string): string { export async function getIDToken(aud?: string): Promise { return await OidcClient.getIDToken(aud) } + +/** + * Markdown summary exports + */ +export {markdownSummary} from './markdown-summary' diff --git a/packages/core/src/markdown-summary.ts b/packages/core/src/markdown-summary.ts index afbd308823..66d528417c 100644 --- a/packages/core/src/markdown-summary.ts +++ b/packages/core/src/markdown-summary.ts @@ -2,7 +2,7 @@ import {EOL} from 'os' import {constants, promises} from 'fs' const {access, appendFile, writeFile} = promises -export interface TableCell { +export interface SummaryTableCell { /** * Cell content */ @@ -24,7 +24,7 @@ export interface TableCell { rowspan?: string } -export class MarkdownSummary { +class MarkdownSummary { static ENV_VAR = 'GITHUB_STEP_SUMMARY' private _buffer: string @@ -41,7 +41,7 @@ export class MarkdownSummary { const filePath = process.env[MarkdownSummary.ENV_VAR] if (!filePath) { throw new Error( - `Unable to find environment variable for ${MarkdownSummary.ENV_VAR}` + `Unable to find environment variable for $${MarkdownSummary.ENV_VAR}` ) } @@ -172,11 +172,11 @@ export class MarkdownSummary { /** * Adds an HTML table to the summary buffer * - * @param {TableCell[]} rows table rows + * @param {SummaryTableCell[]} rows table rows * * @returns {MarkdownSummary} markdown summary instance */ - addTable(rows: TableCell[][]): MarkdownSummary { + addTable(rows: SummaryTableCell[][]): MarkdownSummary { const tableBody = rows .map(row => { const cells = row @@ -262,3 +262,6 @@ export class MarkdownSummary { return this.add(element).addEOL() } } + +// singleton export +export const markdownSummary = new MarkdownSummary()