/* eslint-disable no-await-in-loop */ module.exports = async ({ github, context, core, got }, baseUrl, routes, number) => { if (routes[0] === 'NOROUTE') { return; } const links = routes.map((e) => { const l = e.startsWith('/') ? e : `/${e}`; return `${baseUrl}${l}`; }); let com_l = []; let com = `Successfully [generated](${process.env.GITHUB_SERVER_URL}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}) as following:\n`; for (const lks of links) { core.info(`testing route: ${lks}`); // Intended, one at a time let success = false; let detail; try { // TODO: change me when https://github.com/actions/github-script is run on node20 // const res = await fetch(lks); // if (!res.ok) { // throw res; // } // success = true; // detail = (await res.text()).replace(/\s+(\n|$)/g, '\n'); const res = await got(lks); if (res && res.body) { success = true; detail = res.body.replaceAll(/\s+(\n|$)/g, '\n'); } } catch (error) { // TODO: change me when https://github.com/actions/github-script is run on node20 // detail = `HTTPError: Response code ${err.status} (${err.statusText})`; // const res = await err.text(); // const errInfoList = err.body && res.match(/(?<=