fix: false config change detected because default value was not considered
Massimo Melina committed
Feb 9, 2022 at 10:56 UTC
f9a8a87bbe37f2ae075220369d61aad2e150c573
1 file changed
+2
-2
src/config.ts
+2
-2
@@ -66,7 +66,6 @@ export function getWholeConfig({ omit=[], only=[] }: { omit:string[], only:strin
66
}
67
68
export function setConfig(newCfg: Record<string,any>, partial=false) {
69
- started = true
69
for (const k in newCfg)
70
check(k)
71
const oldKeys = Object.keys(state)
@@ -76,9 +75,10 @@ export function setConfig(newCfg: Record<string,any>, partial=false) {
75
for (const k of oldKeys)
76
if (!newCfg.hasOwnProperty(k))
77
check(k)
78
+ started = true
79
80
function check(k: string) {
81
- const oldV = state[k]
81
+ const oldV = started ? getConfig(k) : state[k] // from second time consider also defaultValue
82
const newV = newCfg[k]
83
const { caster, defaultValue } = configProps[k] ?? {}
84
let v = newV === undefined ? defaultValue : newV