MCPcopy Index your code
hub / github.com/code-pushup/cli / getLighthouseCliArguments

Function getLighthouseCliArguments

examples/plugins/src/lighthouse/src/utils.ts:7–51  ·  view source on GitHub ↗
(
  options: LighthouseCliOptions,
)

Source from the content-addressed store, hash-verified

5import type { LighthouseCliOptions } from './types.js';
6
7export function getLighthouseCliArguments(
8 options: LighthouseCliOptions,
9): string[] {
10 const {
11 url,
12 outputPath = LIGHTHOUSE_REPORT_NAME,
13 onlyAudits = [],
14 verbose = false,
15 headless = false,
16 userDataDir,
17 } = options;
18
19 // eslint-disable-next-line functional/no-let
20 let argsObj: Record<string, unknown> = {
21 _: ['lighthouse', url],
22 verbose,
23 output: 'json',
24 'output-path': outputPath,
25 };
26
27 if (onlyAudits.length > 0) {
28 argsObj = {
29 ...argsObj,
30 onlyAudits: toArray(onlyAudits),
31 };
32 }
33
34 // handle chrome flags
35 // eslint-disable-next-line functional/no-let
36 let chromeFlags: string[] = [];
37 if (headless) {
38 chromeFlags = [...chromeFlags, `--headless=${headless}`];
39 }
40 if (userDataDir) {
41 chromeFlags = [...chromeFlags, `--user-data-dir=${userDataDir}`];
42 }
43 if (chromeFlags.length > 0) {
44 argsObj = {
45 ...argsObj,
46 'chrome-flags': chromeFlags.join(' '),
47 };
48 }
49
50 return objectToCliArgs(argsObj);
51}
52
53export function lhrDetailsToIssueDetails(
54 details = {} as unknown as Result['audits'][string]['details'],

Callers 2

runnerConfigFunction · 0.85
utils.unit.test.tsFile · 0.85

Calls 2

toArrayFunction · 0.90
objectToCliArgsFunction · 0.90

Tested by

no test coverage detected