Make writeToFile return a Promise in JsonFileManager (#2246)
* Make writeToFile return a Promise in JsonFileManager * Add return after promise reject
This commit is contained in:
@@ -16,13 +16,18 @@ export default class JsonFileManager<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
writeToFile(): void {
|
writeToFile(): Promise<void> {
|
||||||
fs.writeFile(this.jsonFile, JSON.stringify(this.json, undefined, 2), (err) => {
|
return new Promise((resolve, reject) => {
|
||||||
if (err) {
|
fs.writeFile(this.jsonFile, JSON.stringify(this.json, undefined, 2), (err) => {
|
||||||
// No real point in bringing electron-log into this otherwise electron-free file
|
if (err) {
|
||||||
// eslint-disable-next-line no-console
|
// No real point in bringing electron-log into this otherwise electron-free file
|
||||||
console.error(err);
|
// eslint-disable-next-line no-console
|
||||||
}
|
console.error(err);
|
||||||
|
reject(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user