cspell
Version:
A Spelling Checker for Code!
18 lines • 819 B
JavaScript
import { setConfigFieldValue } from './adjustConfig.js';
export function applyValuesToConfigFile(config, settings, defaultValues, addComments) {
const currentSettings = config.settings || {};
for (const [k, entry] of Object.entries(defaultValues)) {
const { value: defaultValue, comment } = entry;
const key = k;
const newValue = settings[key];
const oldValue = currentSettings[key];
const value = newValue ?? oldValue ?? defaultValue;
if ((newValue === undefined && oldValue !== undefined) || value === undefined) {
continue;
}
const useComment = (addComments && oldValue === undefined && comment) || undefined;
setConfigFieldValue(config, key, value, useComment);
}
return config;
}
//# sourceMappingURL=config.js.map