MCPcopy Create free account
hub / github.com/SmartThingsCommunity/smartthings-cli / mergeProfiles

Function mergeProfiles

src/lib/cli-config.ts:102–113  ·  view source on GitHub ↗
(preferred: ProfilesByName, secondary: ProfilesByName)

Source from the content-addressed store, hash-verified

100 * Merge profiles from `preferred` and `secondary`, favoring any config entries from `preferred`
101 * over those in `secondary`.
102 */
103export 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
116export const loadConfig = async (description: CLIConfigDescription, logger: Logger): Promise<CLIConfig> => {

Callers 6

loadConfigFunction · 0.85
setConfigKeyFunction · 0.85
resetManagedConfigKeyFunction · 0.85
resetManagedConfigFunction · 0.85
cli-config.test.tsFile · 0.85
makeConfigFunction · 0.85

Calls 1

mergeIntoFunction · 0.85

Tested by 1

makeConfigFunction · 0.68