Fixed settings test.

This commit is contained in:
SamTV12345 2024-03-21 12:29:21 +01:00
parent f9fd9805c0
commit 1905e69463
2 changed files with 26 additions and 1 deletions

View file

@ -629,6 +629,12 @@ const lookupEnvironmentVariables = (obj: MapArrayType<any>) => {
* The environment variable expansion syntax "${ENV_VAR}" is just a string
* of specific form, after all.
*/
if(key === 'undefined' || value === undefined) {
delete obj[key]
continue
}
if ((typeof value !== 'string' && typeof value !== 'object') || value === null) {
obj[key] = value;
continue
@ -723,7 +729,9 @@ const lookupEnvironmentVariables = (obj: MapArrayType<any>) => {
currentNode.addChild(pathToKey, value!)
})
console.log(root.collectFromLeafsUpwards())
//console.log(root.collectFromLeafsUpwards())
//const rooting = root.collectFromLeafsUpwards()
obj = Object.assign(obj, envVars)
return obj;
};

View file

@ -73,6 +73,23 @@ export class SettingsNode {
return collected;
}
public transformObjectWithArrays() {
function isNumeric(str: string|object) {
if (typeof str != "string") return false // we only process strings!
// @ts-ignore
return !isNaN(str) && // use type coercion to parse the _entirety_ of the string (`parseFloat` alone does not do this)...
!isNaN(parseFloat(str)) // ...and ensure strings of whitespace fail
}
let collected: MapArrayType<any> = {};
for (const key in this.children) {
if (isNumeric(key)) {
Object.entries(this.children).map(([key, value]) => {
})
}
}
}
coerceValue = (stringValue: string) => {
// cooked from https://stackoverflow.com/questions/175739/built-in-way-in-javascript-to-check-if-a-string-is-a-valid-number
// @ts-ignore