Skip to content
Snippets Groups Projects
Commit ea9d1a74 authored by michael.minelli's avatar michael.minelli
Browse files

LocalConfig => Bug fix: File can be empty when the soft stop running suddenly

parent 25cf13aa
No related branches found
No related tags found
No related merge requests found
......@@ -32,10 +32,12 @@ class LocalConfig {
fs.writeFileSync(this.configPath, JSON.stringify({}));
}
try {
this._config = JSON.parse(fs.readFileSync(this.configPath).toString());
SessionManager.token = this._config.apiToken;
GitlabManager.token = this._config.gitlabPersonalToken;
} catch ( error ) { }
}
updateConfig(key: LocalConfigKeys, value: any) {
......@@ -45,11 +47,11 @@ class LocalConfig {
(this._config as any)[key] = value;
fs.writeFile(this.configPath, JSON.stringify(this._config, null, 4), (err) => {
if ( err ) {
logger.error(err);
try {
fs.writeFileSync(this.configPath, JSON.stringify(this._config, null, 4));
} catch ( error ) {
logger.error(error);
}
});
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment