1
0
Fork 0

summary: method to clear file and buffer

pull/1014/head
Rob Herley 2022-03-02 23:56:30 -05:00
parent d27bf857e6
commit 339dd63bec
No known key found for this signature in database
GPG Key ID: D1602042C3543B06
2 changed files with 17 additions and 1 deletions

View File

@ -151,6 +151,13 @@ describe('@actions/core/src/markdown-summary', () => {
expect(markdownSummary.isEmptyBuffer()).toBe(true) expect(markdownSummary.isEmptyBuffer()).toBe(true)
}) })
it('clears a buffer and summary file', async () => {
await fs.promises.writeFile(testFilePath, 'content', {encoding: 'utf8'})
await markdownSummary.clear()
await assertSummary('')
expect(markdownSummary.isEmptyBuffer()).toBe(true)
})
it('adds EOL', async () => { it('adds EOL', async () => {
await markdownSummary await markdownSummary
.addRaw(fixtures.text) .addRaw(fixtures.text)

View File

@ -151,6 +151,15 @@ class MarkdownSummary {
return this.emptyBuffer() return this.emptyBuffer()
} }
/**
* Clears the summary buffer and wipes the summary file
*
* @returns {MarkdownSummary} markdown summary instance
*/
async clear(): Promise<MarkdownSummary> {
return this.emptyBuffer().write(true)
}
/** /**
* Returns the current summary buffer as a string * Returns the current summary buffer as a string
* *
@ -170,7 +179,7 @@ class MarkdownSummary {
} }
/** /**
* Clears the summary buffer without writing to summary file * Resets the summary buffer without writing to summary file
* *
* @returns {MarkdownSummary} markdown summary instance * @returns {MarkdownSummary} markdown summary instance
*/ */