mirror of
https://git.mirrors.martin98.com/https://github.com/actions/toolkit
synced 2026-01-04 02:22:56 +08:00
summary: method to clear file and buffer
This commit is contained in:
parent
d27bf857e6
commit
339dd63bec
@ -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)
|
||||||
|
|||||||
@ -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
|
||||||
*/
|
*/
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user