*Heavily simplify config loading and just pass it to the set method, don't try to handle arrays special
This commit is contained in:
parent
792ec3976f
commit
9e8e44b9c5
15
src/index.ts
15
src/index.ts
|
@ -75,21 +75,6 @@ export default class Config {
|
||||||
|
|
||||||
for (const key of Object.keys(settings)) {
|
for (const key of Object.keys(settings)) {
|
||||||
const value = settings[key];
|
const value = settings[key];
|
||||||
|
|
||||||
let keyPath = key.split(".");
|
|
||||||
let isArray =
|
|
||||||
key.includes(".") &&
|
|
||||||
keyPath.length > 1 &&
|
|
||||||
typeof parseInt(keyPath.pop()) === "number";
|
|
||||||
|
|
||||||
if (isArray) {
|
|
||||||
let itemPath = keyPath.join(".");
|
|
||||||
let item = this.get(itemPath, []);
|
|
||||||
item.push(value);
|
|
||||||
this.set(itemPath, item);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.set(key, value);
|
this.set(key, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue