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

This commit is contained in:
Ben Gotow 2016-05-31 12:15:34 -07:00
parent 3b42b2d03b
commit cabc052c18

View file

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