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:
parent
7d95d2cec9
commit
0fc0befe24
2 changed files with 13 additions and 5 deletions
|
@ -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'
|
||||||
|
|
|
@ -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()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue