fixed a bug on the config & now backend does use config values
This commit is contained in:
@@ -55,18 +55,31 @@ export function getConfig() {
|
||||
};
|
||||
}
|
||||
|
||||
function sanitizeLoadedConfig(loaded) {
|
||||
return {
|
||||
library: loaded.library,
|
||||
paths: loaded.paths
|
||||
};
|
||||
}
|
||||
|
||||
export function setConfig(partialConfig) {
|
||||
ensureConfigFile();
|
||||
|
||||
const current = getConfig();
|
||||
const next = deepMerge(current, partialConfig);
|
||||
const raw = fs.readFileSync(CONFIG_PATH, 'utf8');
|
||||
const loadedRaw = yaml.load(raw) || {};
|
||||
const loaded = sanitizeLoadedConfig(loadedRaw);
|
||||
|
||||
fs.writeFileSync(
|
||||
CONFIG_PATH,
|
||||
yaml.dump(next),
|
||||
'utf8'
|
||||
const next = deepMerge(
|
||||
structuredClone(DEFAULT_CONFIG),
|
||||
deepMerge(loaded, partialConfig)
|
||||
);
|
||||
|
||||
const toSave = {
|
||||
library: next.library,
|
||||
paths: next.paths
|
||||
};
|
||||
|
||||
fs.writeFileSync(CONFIG_PATH, yaml.dump(toSave), 'utf8');
|
||||
return next;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user