( urls: string[], flags: LighthouseCliFlags = DEFAULT_CLI_FLAGS, )
| 29 | } from './utils.js'; |
| 30 | |
| 31 | export function createRunnerFunction( |
| 32 | urls: string[], |
| 33 | flags: LighthouseCliFlags = DEFAULT_CLI_FLAGS, |
| 34 | ): RunnerFunction { |
| 35 | return withLocalTmpDir(async (): Promise<AuditOutputs> => { |
| 36 | const config = await getConfig(flags); |
| 37 | const normalizationFlags = enrichFlags(flags); |
| 38 | const urlsCount = urls.length; |
| 39 | const isSingleUrl = !shouldExpandForUrls(urlsCount); |
| 40 | |
| 41 | const allResults = await asyncSequential(urls, (url, urlIndex) => { |
| 42 | const enrichedFlags = isSingleUrl |
| 43 | ? normalizationFlags |
| 44 | : enrichFlags(flags, urlIndex + 1); |
| 45 | const step = { urlIndex, urlsCount }; |
| 46 | return runLighthouseForUrl(url, enrichedFlags, config, step); |
| 47 | }); |
| 48 | |
| 49 | const collectedResults = allResults.filter(res => res != null); |
| 50 | if (collectedResults.length === 0) { |
| 51 | throw new Error( |
| 52 | isSingleUrl |
| 53 | ? 'Lighthouse did not produce a result.' |
| 54 | : 'Lighthouse failed to produce results for all URLs.', |
| 55 | ); |
| 56 | } |
| 57 | |
| 58 | logResultsForAllUrls(collectedResults); |
| 59 | |
| 60 | const auditOutputs: AuditOutputs = collectedResults.flatMap( |
| 61 | res => res.auditOutputs, |
| 62 | ); |
| 63 | return filterAuditOutputs(auditOutputs, normalizationFlags); |
| 64 | }); |
| 65 | } |
| 66 | |
| 67 | type ResultForUrl = { |
| 68 | url: string; |
nothing calls this directly
no test coverage detected