Skip to content

Bump word-wrap from 1.2.3 to 1.2.5 #56

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix tests
  • Loading branch information
Eesh Tyagi authored and Eesh Tyagi committed Sep 16, 2023
commit 364486ca5b3148c4a4227df7dcc21e4ab37a868d
2 changes: 1 addition & 1 deletion dist/main.js

Large diffs are not rendered by default.

72 changes: 38 additions & 34 deletions src/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ const listComments = async ({ client, context, prNumber, hiddenHeader }) => {
};

const insertComment = ({ client, context, prNumber, body }, hiddenHeader) =>
client.issues.createComment({
client.issues?.createComment({
...context.repo,
issue_number: prNumber,
body: appendHiddenHeaderToComment(body, hiddenHeader),
});

const updateComment = ({ client, context, body, commentId }, hiddenHeader) =>
client.issues.updateComment({
client.issues?.updateComment({
...context.repo,
comment_id: commentId,
body: appendHiddenHeaderToComment(body, hiddenHeader),
Expand All @@ -44,7 +44,7 @@ const updateComment = ({ client, context, body, commentId }, hiddenHeader) =>
const deleteComments = ({ client, context, comments }) =>
Promise.all(
comments.map(({ id }) =>
client.issues.deleteComment({
client.issues?.deleteComment({
...context.repo,
comment_id: id,
}),
Expand All @@ -58,37 +58,41 @@ export const upsertComment = async ({
body,
hiddenHeader,
}) => {
const existingComments = await listComments({
client,
context,
prNumber,
hiddenHeader,
});
const last = existingComments.pop();
if (client.issues) {
const existingComments = await listComments({
client,
context,
prNumber,
hiddenHeader,
});
const last = existingComments.pop();

await deleteComments({
client,
context,
comments: existingComments,
});
await deleteComments({
client,
context,
comments: existingComments,
});

return last
? updateComment(
{
client,
context,
body,
commentId: last.id,
},
hiddenHeader,
)
: insertComment(
{
client,
context,
prNumber,
body,
},
hiddenHeader,
);
}

return last
? updateComment(
{
client,
context,
body,
commentId: last.id,
},
hiddenHeader,
)
: insertComment(
{
client,
context,
prNumber,
body,
},
hiddenHeader,
);
return "";
};