1
0
Fork 0
mirror of https://github.com/actions/toolkit synced 2025-05-10 09:03:02 +00:00

export markdownSummary singleton from core

This commit is contained in:
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> { export async function getIDToken(aud?: string): Promise<string> {
return await OidcClient.getIDToken(aud) 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' import {constants, promises} from 'fs'
const {access, appendFile, writeFile} = promises const {access, appendFile, writeFile} = promises
export interface TableCell { export interface SummaryTableCell {
/** /**
* Cell content * Cell content
*/ */
@ -24,7 +24,7 @@ export interface TableCell {
rowspan?: string rowspan?: string
} }
export class MarkdownSummary { class MarkdownSummary {
static ENV_VAR = 'GITHUB_STEP_SUMMARY' static ENV_VAR = 'GITHUB_STEP_SUMMARY'
private _buffer: string private _buffer: string
@ -41,7 +41,7 @@ export class MarkdownSummary {
const filePath = process.env[MarkdownSummary.ENV_VAR] const filePath = process.env[MarkdownSummary.ENV_VAR]
if (!filePath) { if (!filePath) {
throw new Error( 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 * Adds an HTML table to the summary buffer
* *
* @param {TableCell[]} rows table rows * @param {SummaryTableCell[]} rows table rows
* *
* @returns {MarkdownSummary} markdown summary instance * @returns {MarkdownSummary} markdown summary instance
*/ */
addTable(rows: TableCell[][]): MarkdownSummary { addTable(rows: SummaryTableCell[][]): MarkdownSummary {
const tableBody = rows const tableBody = rows
.map(row => { .map(row => {
const cells = row const cells = row
@ -262,3 +262,6 @@ export class MarkdownSummary {
return this.add(element).addEOL() return this.add(element).addEOL()
} }
} }
// singleton export
export const markdownSummary = new MarkdownSummary()