chore: Make Lighthouse CI run on local build (#9447)

This commit is contained in:
Sébastien Lorber 2023-10-25 11:44:47 +02:00 committed by GitHub
parent c6762a2542
commit dd03a25a71
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 37 additions and 15 deletions

View file

@ -26,6 +26,18 @@ const scoreEntry = (rawScore) => {
return `${scoreIcon} ${score}`;
};
/**
* @param {string} url
* @returns {module:url.URL}
*/
function createURL(url) {
try {
return new URL(url);
} catch (e) {
throw new Error(`Can't create URL for string=${url}`, {cause: e});
}
}
/**
* @param {Object} param0
* @param {string} param0.url
@ -34,7 +46,7 @@ const scoreEntry = (rawScore) => {
*/
const createMarkdownTableRow = ({url, summary, reportUrl}) =>
[
`| [${new URL(url).pathname}](${url})`,
`| [${createURL(url).pathname}](${url})`,
.../** @type {(keyof LighthouseSummary)[]} */ (
Object.keys(summaryKeys)
).map((k) => scoreEntry(summary[k])),