(env: EnvMap, command: string | null)
| 122 | } |
| 123 | |
| 124 | function readEnvFlagDefaults(env: EnvMap, command: string | null): Partial<CliFlags> { |
| 125 | const flags: Partial<CliFlags> = {}; |
| 126 | for (const spec of getConfigurableOptionSpecs(command)) { |
| 127 | if (spec.key === 'installSource') continue; |
| 128 | const envNames = spec.env.names; |
| 129 | const envValue = envNames |
| 130 | .map((name) => ({ name, value: env[name] })) |
| 131 | .find((entry) => typeof entry.value === 'string' && entry.value.trim().length > 0); |
| 132 | if (!envValue) continue; |
| 133 | (flags as Record<string, unknown>)[spec.key] = parseOptionValueFromSource( |
| 134 | spec, |
| 135 | envValue.value as string, |
| 136 | `environment variable ${envValue.name}`, |
| 137 | envValue.name, |
| 138 | ); |
| 139 | } |
| 140 | return flags; |
| 141 | } |
no test coverage detected