diff --git a/__tests__/comment.test.ts b/__tests__/comment.test.ts index 7ad8271..b0a75f5 100644 --- a/__tests__/comment.test.ts +++ b/__tests__/comment.test.ts @@ -142,7 +142,7 @@ describe("updateComment", () => { expect(octokit.graphql).toBeCalledWith(expect.any(String), { input: { id: "456", - body: "hello there\n\nhello there" + body: "hello there\nhello there\n" } }) }) diff --git a/src/comment.ts b/src/comment.ts index 0da254a..ff6e0d9 100644 --- a/src/comment.ts +++ b/src/comment.ts @@ -20,7 +20,7 @@ function bodyWithHeader(body: string, header: string): string { } function bodyWithoutHeader(body: string, header: string): string { - return body.replace(`\n${headerComment(header)}`, ""); + return body.replace(`\n${headerComment(header)}`, "") } export async function findPreviousComment( @@ -92,8 +92,9 @@ export async function updateComment( if (!body && !previousBody) return core.warning("Comment body cannot be blank") - if (previousBody) - let rawPreviousBody = bodyWithoutHeader(previousBody, header) + const rawPreviousBody: String = previousBody + ? bodyWithoutHeader(previousBody, header) + : "" await octokit.graphql( `