fix(config): When resetting config, use template file

This commit is contained in:
Ben Gotow 2016-05-31 12:15:34 -07:00
parent 3df2b1e3be
commit 84ed8faf6b

View file

@ -28,12 +28,16 @@ export default class ConfigPersistenceManager {
}
if (!fs.existsSync(this.configFilePath)) {
const templateConfigPath = path.join(this.resourcePath, 'dot-nylas', 'config.json');
const templateConfig = fs.readFileSync(templateConfigPath);
fs.writeFileSync(this.configFilePath, templateConfig);
this.writeTemplateConfigFile();
}
}
writeTemplateConfigFile() {
const templateConfigPath = path.join(this.resourcePath, 'dot-nylas', 'config.json');
const templateConfig = fs.readFileSync(templateConfigPath);
fs.writeFileSync(this.configFilePath, templateConfig);
}
load() {
this.userWantsToPreserveErrors = false;
@ -59,8 +63,11 @@ export default class ConfigPersistenceManager {
} else if (clickedIndex === 1) {
this.load();
} else {
this.settings = {};
this.emitChangeEvent();
if (fs.existsSync(this.configFilePath)) {
fs.unlinkSync(this.configFilePath);
}
this.writeTemplateConfigFile();
this.load();
}
}
}