From f10a49b18ae4198070bfe0ab9d6de541bfbd5c24 Mon Sep 17 00:00:00 2001 From: Oj Date: Sat, 11 Dec 2021 21:50:23 +0000 Subject: [PATCH] [Settings] Small refactor: add comments, tweak some variable naming --- src/utils/Settings.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/utils/Settings.js b/src/utils/Settings.js index 6b255f7..5165bbb 100644 --- a/src/utils/Settings.js +++ b/src/utils/Settings.js @@ -8,7 +8,7 @@ class Settings { // Heavily based on original for compat, but simplified and twe try { this.lastSaved = readFileSync(this.path); this.settings = JSON.parse(this.lastSaved); - } catch (e) { + } catch (_e) { this.lastSaved = ''; this.settings = {}; } @@ -35,7 +35,7 @@ class Settings { // Heavily based on original for compat, but simplified and twe } save() { - if (this.lastModified && this.lastModified !== this.getLastModified()) { + if (this.lastModified && this.lastModified !== this.getLastModified()) { // File was last modified after Settings was made, so was externally edited therefore we don't save over log('AppSettings', 'Refusing to save settings.json due to last modified date mismatch'); return; } @@ -43,7 +43,7 @@ class Settings { // Heavily based on original for compat, but simplified and twe try { const toSave = JSON.stringify(this.settings, null, 2); - if (this.lastSaved != toSave) { + if (this.lastSaved != toSave) { // Settings has changed this.lastSaved = toSave; writeFileSync(this.path, toSave); @@ -51,9 +51,9 @@ class Settings { // Heavily based on original for compat, but simplified and twe this.lastModified = this.getLastModified(); } - log('AppSettings', 'Saved settings.json'); - } catch (err) { - log('AppSettings', 'Failed to save settings.json', err); + log('AppSettings', 'Saved', this.path); + } catch (e) { + log('AppSettings', 'Failed to save', this.path, e); } }