Skip to content

Commit

Permalink
Only show fallback text if both tables are empty
Browse files Browse the repository at this point in the history
  • Loading branch information
canac committed Apr 24, 2024
1 parent a12c8d9 commit db8bfa0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -127878,7 +127878,7 @@ function getSign(bytes) {
;// CONCATENATED MODULE: ./src/text-format.ts
function formatTextFragments(...text) {
return text
.map((fragment) => fragment.trim())
.map((fragment) => fragment === null || fragment === void 0 ? void 0 : fragment.trim())
.filter(Boolean)
.join('\n\n');
}
Expand All @@ -127897,7 +127897,7 @@ async function createOrReplaceComment({ octokit, issueNumber, title, shaInfo, ro
issueNumber,
text: title,
});
const body = formatTextFragments(title, shaInfo, routesTable !== null && routesTable !== void 0 ? routesTable : FALLBACK_COMPARISON_TEXT, dynamicTable !== null && dynamicTable !== void 0 ? dynamicTable : FALLBACK_COMPARISON_TEXT);
const body = formatTextFragments(title, shaInfo, routesTable, dynamicTable, !(routesTable === null || routesTable === void 0 ? void 0 : routesTable.trim()) && !(dynamicTable === null || dynamicTable === void 0 ? void 0 : dynamicTable.trim()) ? FALLBACK_COMPARISON_TEXT : null);
if (existingComment) {
console.log(`Updating comment ${existingComment.id}`);
const response = await octokit.rest.issues.updateComment(Object.assign(Object.assign({}, github.context.repo), { comment_id: existingComment.id, body }));
Expand Down
5 changes: 3 additions & 2 deletions src/comments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ export async function createOrReplaceComment({
const body = formatTextFragments(
title,
shaInfo,
routesTable ?? FALLBACK_COMPARISON_TEXT,
dynamicTable ?? FALLBACK_COMPARISON_TEXT,
routesTable,
dynamicTable,
!routesTable?.trim() && !dynamicTable?.trim() ? FALLBACK_COMPARISON_TEXT : null,
);

if (existingComment) {
Expand Down
4 changes: 2 additions & 2 deletions src/text-format.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export function formatTextFragments(...text: string[]) {
export function formatTextFragments(...text: Array<string | null>) {
return text
.map((fragment) => fragment.trim())
.map((fragment) => fragment?.trim())
.filter(Boolean)
.join('\n\n');
}

0 comments on commit db8bfa0

Please sign in to comment.