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

Function normalizeFlags

packages/plugin-lighthouse/src/lib/normalize-flags.ts:38–63  ·  view source on GitHub ↗
(flags?: LighthouseOptions)

Source from the content-addressed store, hash-verified

36]);
37
38export function normalizeFlags(flags?: LighthouseOptions): LighthouseCliFlags {
39 const prefilledFlags = { ...DEFAULT_LIGHTHOUSE_OPTIONS, ...flags };
40
41 logUnsupportedFlagsInUse(prefilledFlags);
42
43 return Object.fromEntries(
44 Object.entries(prefilledFlags)
45 .filter(
46 ([flagName]) =>
47 !LIGHTHOUSE_UNSUPPORTED_CLI_FLAGS.has(
48 flagName as UnsupportedCliFlags,
49 ),
50 )
51 // in code-pushup lighthouse categories are mapped as groups, therefor we had to rename "onlyCategories" to "onlyGroups" for the user of the plugin as it was confusing
52 .map(([key, v]) => [key === 'onlyGroups' ? 'onlyCategories' : key, v])
53 // onlyAudits and onlyCategories cannot be empty arrays, otherwise skipAudits is ignored by lighthouse
54 .filter(([_, v]) => !(Array.isArray(v) && v.length === 0))
55 // undefined | string | string[] => string[] (empty for undefined)
56 .map(([key, v]) => {
57 if (!REFINED_STRING_OR_STRING_ARRAY.has(key as never)) {
58 return [key, v];
59 }
60 return [key, Array.isArray(v) ? v : v == null ? [] : [v]];
61 }),
62 ) as LighthouseCliFlags;
63}
64
65export function logUnsupportedFlagsInUse(
66 flags: LighthouseOptions,

Callers 2

lighthousePluginFunction · 0.85

Calls 1

logUnsupportedFlagsInUseFunction · 0.85

Tested by

no test coverage detected