From 374aa35dd2a9bf3f32ac0d21562eba4dcb5df9c0 Mon Sep 17 00:00:00 2001 From: Braun Patrik Date: Tue, 24 Jan 2017 20:37:16 +0100 Subject: [PATCH] fixing config loading --- backend/config/ConfigLoader.ts | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/backend/config/ConfigLoader.ts b/backend/config/ConfigLoader.ts index 4b00fdde..c0f4e1c1 100644 --- a/backend/config/ConfigLoader.ts +++ b/backend/config/ConfigLoader.ts @@ -18,7 +18,7 @@ export class ConfigLoader { } }); this.processHierarchyVar(configObject, varAliases); - this.loadObject(configObject, process.env); + this.processHierarchyVar(configObject, process.env); }; private static processArguments(configObject: any) { @@ -95,16 +95,22 @@ export class ConfigLoader { } } - private static loadObject(targetObject: any, sourceObject: any) { + + private static loadObject(targetObject, sourceObject) { Object.keys(sourceObject).forEach((key) => { if (typeof targetObject[key] === "undefined") { return; } - if (typeof targetObject[key] === "object") { - this.loadObject(targetObject[key], sourceObject[key]); - } else { - targetObject[key] = sourceObject[key]; + + if (Array.isArray(targetObject[key])) { + return targetObject[key] = sourceObject[key]; } + + if (typeof targetObject[key] === "object") { + return this.loadObject(targetObject[key], sourceObject[key]); + } + + targetObject[key] = sourceObject[key]; }); } } \ No newline at end of file