( source: Record<string, unknown>, sourceLabel: string, )
| 94 | } |
| 95 | |
| 96 | function parseConfigObject( |
| 97 | source: Record<string, unknown>, |
| 98 | sourceLabel: string, |
| 99 | ): Partial<CliFlags> { |
| 100 | const flags: Partial<CliFlags> = {}; |
| 101 | for (const [rawKey, rawValue] of Object.entries(source)) { |
| 102 | if (rawKey === 'installSource') { |
| 103 | flags.installSource = parseInstallSourceConfig(rawValue, sourceLabel); |
| 104 | continue; |
| 105 | } |
| 106 | const key = rawKey as FlagKey; |
| 107 | const spec = getOptionSpec(key); |
| 108 | if (!spec) { |
| 109 | throw new AppError('INVALID_ARGS', `Unknown config key "${rawKey}" in ${sourceLabel}.`); |
| 110 | } |
| 111 | if (!spec.config.enabled) { |
| 112 | throw new AppError('INVALID_ARGS', `Unsupported config key "${rawKey}" in ${sourceLabel}.`); |
| 113 | } |
| 114 | (flags as Record<string, unknown>)[key] = parseOptionValueFromSource( |
| 115 | spec, |
| 116 | rawValue, |
| 117 | sourceLabel, |
| 118 | rawKey, |
| 119 | ); |
| 120 | } |
| 121 | return flags; |
| 122 | } |
| 123 | |
| 124 | function readEnvFlagDefaults(env: EnvMap, command: string | null): Partial<CliFlags> { |
| 125 | const flags: Partial<CliFlags> = {}; |
no test coverage detected