mirror of
https://github.com/marocchino/sticky-pull-request-comment.git
synced 2026-05-22 10:55:54 +00:00
fix: when message has no {{{content}}} placeholder, return message as-is
Agent-Logs-Url: https://github.com/marocchino/sticky-pull-request-comment/sessions/b6492aa3-c55c-41f7-b43e-12cc3f2c3002 Co-authored-by: marocchino <128431+marocchino@users.noreply.github.com>
This commit is contained in:
parent
207e3732e6
commit
c9b1ea3b58
2 changed files with 7 additions and 4 deletions
|
|
@ -237,7 +237,7 @@ describe("getBody", () => {
|
|||
expect(await config.getBody()).toBe("hi there\n\n---\nhi there\n")
|
||||
})
|
||||
|
||||
test("uses file content as body when path is provided but message has no {{{content}}} placeholder", async () => {
|
||||
test("uses message as body when path is provided but message has no {{{content}}} placeholder", async () => {
|
||||
const {config, core} = await loadConfig()
|
||||
vi.mocked(core.getMultilineInput).mockReturnValue(["__tests__/assets/result"])
|
||||
vi.mocked(core.getInput).mockImplementation(name => {
|
||||
|
|
@ -247,7 +247,7 @@ describe("getBody", () => {
|
|||
mockGlobCreate.mockResolvedValue({
|
||||
glob: vi.fn().mockResolvedValue([resolve("__tests__/assets/result")]),
|
||||
})
|
||||
expect(await config.getBody()).toBe("hi there\n")
|
||||
expect(await config.getBody()).toBe("no placeholder here")
|
||||
})
|
||||
|
||||
test("embeds multiple files content in message when {{{content}}} placeholder is used", async () => {
|
||||
|
|
|
|||
|
|
@ -61,8 +61,11 @@ export async function getBody(): Promise<string> {
|
|||
const fileContent = (await globber.glob())
|
||||
.map(path => readFileSync(path, "utf-8"))
|
||||
.join("\n")
|
||||
if (messageInput && messageInput.includes("{{{content}}}")) {
|
||||
return messageInput.replace(/\{\{\{content\}\}\}/g, fileContent)
|
||||
if (messageInput) {
|
||||
if (messageInput.includes("{{{content}}}")) {
|
||||
return messageInput.replace(/\{\{\{content\}\}\}/g, fileContent)
|
||||
}
|
||||
return messageInput
|
||||
}
|
||||
return fileContent
|
||||
} catch (error) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue