| 100 | * Merge profiles from `preferred` and `secondary`, favoring any config entries from `preferred` |
| 101 | * over those in `secondary`. |
| 102 | */ |
| 103 | export const mergeProfiles = (preferred: ProfilesByName, secondary: ProfilesByName): ProfilesByName => { |
| 104 | const mergeInto = (into: ProfilesByName, from: ProfilesByName): ProfilesByName => { |
| 105 | for (const [profileName, profileData] of Object.entries(from)) { |
| 106 | if (!(profileName in into)) { |
| 107 | into[profileName] = {} |
| 108 | } |
| 109 | Object.assign(into[profileName], profileData) |
| 110 | } |
| 111 | return into |
| 112 | } |
| 113 | return mergeInto(mergeInto({}, secondary), preferred) |
| 114 | } |
| 115 | |
| 116 | export const loadConfig = async (description: CLIConfigDescription, logger: Logger): Promise<CLIConfig> => { |