Skip to content
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

Narrow last results column in broken links issue #1191

Merged
merged 5 commits into from
Feb 11, 2020
Merged
Changes from all commits
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
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