1
0
Fork 0

export markdownSummary singleton from core

pull/1014/head
Rob Herley 2022-03-01 21:32:26 -05:00
parent 7d95d2cec9
commit 0fc0befe24
No known key found for this signature in database
GPG Key ID: D1602042C3543B06
2 changed files with 13 additions and 5 deletions

View File

@ -359,3 +359,8 @@ export function getState(name: string): string {
export async function getIDToken(aud?: string): Promise<string> {
return await OidcClient.getIDToken(aud)
}
/**
* Markdown summary exports
*/
export {markdownSummary} from './markdown-summary'

View File

@ -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()