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