Skip to content

Commit

Permalink
export markdownSummary singleton from core
Browse files Browse the repository at this point in the history
  • Loading branch information
robherley committed Mar 2, 2022
1 parent 7d95d2c commit 0fc0bef
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
5 changes: 5 additions & 0 deletions packages/core/src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
13 changes: 8 additions & 5 deletions packages/core/src/markdown-summary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -24,7 +24,7 @@ export interface TableCell {
rowspan?: string
}

export class MarkdownSummary {
class MarkdownSummary {
static ENV_VAR = 'GITHUB_STEP_SUMMARY'
private _buffer: string

Expand All @@ -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}`
)
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -262,3 +262,6 @@ export class MarkdownSummary {
return this.add(element).addEOL()
}
}

// singleton export
export const markdownSummary = new MarkdownSummary()

0 comments on commit 0fc0bef

Please sign in to comment.