aboutsummaryrefslogtreecommitdiffstats
path: root/packages/main/src/controllers/initConfig.ts
diff options
context:
space:
mode:
authorLibravatar Kristóf Marussy <kristof@marussy.com>2022-01-09 20:33:53 +0100
committerLibravatar Kristóf Marussy <kristof@marussy.com>2022-01-09 20:33:53 +0100
commitd85f09cbed5f3d2501f791e689011ae127df1cbb (patch)
tree0ed5be55dd5d3dec1d51eb60e7ff229274030a57 /packages/main/src/controllers/initConfig.ts
parentbuild: Disable single-run eslint-typescript (diff)
downloadsophie-d85f09cbed5f3d2501f791e689011ae127df1cbb.tar.gz
sophie-d85f09cbed5f3d2501f791e689011ae127df1cbb.tar.zst
sophie-d85f09cbed5f3d2501f791e689011ae127df1cbb.zip
build: Add prettier
eslint will also enforce prettier rules, so there is no need to call prettier separately in CI. Signed-off-by: Kristóf Marussy <kristof@marussy.com>
Diffstat (limited to 'packages/main/src/controllers/initConfig.ts')
-rw-r--r--packages/main/src/controllers/initConfig.ts21
1 files changed, 12 insertions, 9 deletions
diff --git a/packages/main/src/controllers/initConfig.ts b/packages/main/src/controllers/initConfig.ts
index 1d40762..e83b8da 100644
--- a/packages/main/src/controllers/initConfig.ts
+++ b/packages/main/src/controllers/initConfig.ts
@@ -59,20 +59,23 @@ export default async function initConfig(
59 lastSnapshotOnDisk = snapshot; 59 lastSnapshotOnDisk = snapshot;
60 } 60 }
61 61
62 if (!await readConfig()) { 62 if (!(await readConfig())) {
63 log.info('Config file was not found'); 63 log.info('Config file was not found');
64 await writeConfig(); 64 await writeConfig();
65 log.info('Created config file'); 65 log.info('Created config file');
66 } 66 }
67 67
68 const disposeOnSnapshot = onSnapshot(config, debounce((snapshot) => { 68 const disposeOnSnapshot = onSnapshot(
69 // We can compare snapshots by reference, since it is only recreated on store changes. 69 config,
70 if (lastSnapshotOnDisk !== snapshot) { 70 debounce((snapshot) => {
71 writeConfig().catch((err) => { 71 // We can compare snapshots by reference, since it is only recreated on store changes.
72 log.error('Failed to write config on config change', err); 72 if (lastSnapshotOnDisk !== snapshot) {
73 }); 73 writeConfig().catch((err) => {
74 } 74 log.error('Failed to write config on config change', err);
75 }, debounceTime)); 75 });
76 }
77 }, debounceTime),
78 );
76 79
77 const disposeWatcher = persistenceService.watchConfig(async () => { 80 const disposeWatcher = persistenceService.watchConfig(async () => {
78 try { 81 try {