Skip to content

Commit

Permalink
Narrow last results column in broken links issue (#1191)
Browse files Browse the repository at this point in the history
* Narrow last results column in broken links issue
* Fix unwanted extra column
* Code style
  • Loading branch information
fxedel authored Feb 11, 2020
1 parent 7f960ef commit 9dd7f67
Showing 1 changed file with 16 additions and 22 deletions.
38 changes: 16 additions & 22 deletions tests/external-links.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,21 +278,18 @@ async function updateGithubIssue(urlResults) {
const firstContentLine = lines.findIndex(line => line.startsWith(`|`)) + 2;
lines.splice(0, firstContentLine); // delete first lines which only hold general data
for (const line of lines) {
const cells = line.split(`|`)
.map(str => str.trim())
.filter(str => str.length > 0);
const [, url, lastResults] = line.match(/^\| (.*) <td nowrap>(.*)<\/td>$/);

const url = cells.shift();
linkData[url] = cells.map(cell => {
if (cell === `:heavy_check_mark:`) {
linkData[url] = lastResults.split(`&nbsp;`).map(item => {
if (item === `:heavy_check_mark:`) {
return {
failed: false,
message: null,
jobUrl: null
};
}

const [, jobUrl, message] = cell.match(/<a href="(.*)" title="(.*)">:x:<\/a>/);
const [, jobUrl, message] = item.match(/<a href="(.*)" title="(.*)">:x:<\/a>/);

return {
failed: true,
Expand Down Expand Up @@ -374,22 +371,19 @@ async function updateGithubIssue(urlResults) {
``,
`**Last updated:** ${(new Date()).toISOString()}`,
``,
`| URL | today | -1d | -2d | -3d | -4d | -5d | -6d |`,
`|-----|-------|-----|-----|-----|-----|-----|-----|`,
`| URL <th nowrap>today … 6 days ago</th>`,
`|--------------------------------------|`,
...Object.entries(linkData).map(([url, statuses]) => {
const columns = [
url,
...statuses.map(status => {
if (!status.failed) {
return `:heavy_check_mark:`;
}

const message = status.message.replace(`\n`, ` `).replace(`"`, `&quot;`);
return `<a href="${status.jobUrl}" title="${message}">:x:</a>`;
})
];

return `| ${columns.join(` | `)} |`;
const statusIcons = statuses.map(status => {
if (!status.failed) {
return `:heavy_check_mark:`;
}

const message = status.message.replace(`\n`, ` `).replace(`"`, `&quot;`);
return `<a href="${status.jobUrl}" title="${message}">:x:</a>`;
}).join(`&nbsp;`);

return `| ${url} <td nowrap>${statusIcons}</td>`;
})
];

Expand Down

0 comments on commit 9dd7f67

Please sign in to comment.