diff --git a/tests/external-links.js b/tests/external-links.js index d85bea3739..aa2dd99ada 100755 --- a/tests/external-links.js +++ b/tests/external-links.js @@ -269,10 +269,10 @@ async function updateGithubIssue(urlResults) { try { const lines = body.split(/\r?\n/); // support both \n and \r\n newline types - const firstContentLine = lines.findIndex(line => line.startsWith(`|`)) + 2; + const firstContentLine = lines.indexOf(``) + 2; lines.splice(0, firstContentLine); // delete first lines which only hold general data for (const line of lines) { - const [, url, lastResults] = line.match(/^\| (.*) `; + }); const lines = [ `*Auto-generated content by \`${scriptName}\`.*`, ``, `**Last updated:** ${new Date().toISOString()}`, ``, - `| URL `, - `|--------------------------------------|`, - ...Object.entries(linkData).map(([url, statuses]) => { - const statusIcons = statuses.map(status => { - if (!status.failed) { - return `:heavy_check_mark:`; - } - - const message = status.message.replaceAll(`\n`, ` `).replaceAll(`"`, `"`); - const emoji = getFailedEmoji(status.message); - return `${emoji}`; - }).join(` `); - - return `| ${url} `; - }), + `
(.*)<\/td>$/); + const [, lastResults, url] = line.match(/
(.*?)<\/td> { if (item === `:heavy_check_mark:`) { @@ -358,34 +358,41 @@ async function updateGithubIssue(urlResults) { return linkData; } + /** + * @param {LinkStatus} status The status to get the linked emoji for. + * @returns {string} An emoji, wrapped in a link to the failed job if applicable. + */ + function getStatusEmojiLink(status) { + if (!status.failed) { + return `:heavy_check_mark:`; + } + + const message = status.message.replaceAll(`\n`, ` `).replaceAll(`"`, `"`); + const emoji = getFailedEmoji(status.message); + return `${emoji}`; + } + /** * @param {LinkData} linkData The new link data from which to create the issue body. * @returns {string} The new issue body (in Markdown and HTML) from the given link data. */ function getBodyFromLinkData(linkData) { const scriptName = import.meta.url.split(`/`).slice(-2).join(`/`); + const rows = Object.entries(linkData).map(([url, statuses]) => { + const statusIcons = statuses.map(status => getStatusEmojiLink(status)).join(` `); + const link = `${url}`; + return `
${statusIcons}${link}
today … 6 days ago${statusIcons}
`, + ``, + ...rows, + `
today … 6 days agoURL
`, ]; - return lines.join(`\n`); }