mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-17 02:56:57 +02:00
chore: Make Lighthouse CI run on local build (#9447)
This commit is contained in:
parent
c6762a2542
commit
dd03a25a71
3 changed files with 37 additions and 15 deletions
|
@ -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])),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue