diff options
Diffstat (limited to 'packages/main/src/services/impl')
-rw-r--r-- | packages/main/src/services/impl/ConfigPersistenceServiceImpl.ts | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/packages/main/src/services/impl/ConfigPersistenceServiceImpl.ts b/packages/main/src/services/impl/ConfigPersistenceServiceImpl.ts index 2d19632..df8c807 100644 --- a/packages/main/src/services/impl/ConfigPersistenceServiceImpl.ts +++ b/packages/main/src/services/impl/ConfigPersistenceServiceImpl.ts | |||
@@ -19,18 +19,20 @@ | |||
19 | */ | 19 | */ |
20 | import { watch } from 'fs'; | 20 | import { watch } from 'fs'; |
21 | import { readFile, stat, writeFile } from 'fs/promises'; | 21 | import { readFile, stat, writeFile } from 'fs/promises'; |
22 | import JSON5 from 'json5'; | ||
23 | import { throttle } from 'lodash-es'; | ||
24 | import { join } from 'path'; | 22 | import { join } from 'path'; |
25 | 23 | ||
26 | import type { ConfigPersistenceService, ReadConfigResult } from '../ConfigPersistenceService.js'; | 24 | import JSON5 from 'json5'; |
27 | import type { ConfigSnapshotOut } from '../../stores/Config.js'; | 25 | import throttle from 'lodash-es/throttle'; |
28 | import { Disposer } from '../../utils/disposer'; | 26 | |
29 | import { getLogger } from '../../utils/logging'; | 27 | import type { ConfigSnapshotOut } from '../../stores/Config'; |
28 | import type Disposer from '../../utils/Disposer'; | ||
29 | import { getLogger } from '../../utils/log'; | ||
30 | import type ConfigPersistenceService from '../ConfigPersistenceService'; | ||
31 | import type { ReadConfigResult } from '../ConfigPersistenceService'; | ||
30 | 32 | ||
31 | const log = getLogger('configPersistence'); | 33 | const log = getLogger('configPersistence'); |
32 | 34 | ||
33 | export class ConfigPersistenceServiceImpl implements ConfigPersistenceService { | 35 | export default class ConfigPersistenceServiceImpl implements ConfigPersistenceService { |
34 | private readonly configFilePath: string; | 36 | private readonly configFilePath: string; |
35 | 37 | ||
36 | private writingConfig = false; | 38 | private writingConfig = false; |
@@ -103,7 +105,7 @@ export class ConfigPersistenceServiceImpl implements ConfigPersistenceService { | |||
103 | 'whish is newer than last written', | 105 | 'whish is newer than last written', |
104 | this.timeLastWritten, | 106 | this.timeLastWritten, |
105 | ); | 107 | ); |
106 | return callback(); | 108 | await callback(); |
107 | } | 109 | } |
108 | }, throttleMs); | 110 | }, throttleMs); |
109 | 111 | ||
@@ -115,7 +117,7 @@ export class ConfigPersistenceServiceImpl implements ConfigPersistenceService { | |||
115 | if (eventType === 'change' | 117 | if (eventType === 'change' |
116 | && (filename === this.configFileName || filename === null)) { | 118 | && (filename === this.configFileName || filename === null)) { |
117 | configChanged()?.catch((err) => { | 119 | configChanged()?.catch((err) => { |
118 | console.log('Unhandled error while listening for config changes', err); | 120 | log.error('Unhandled error while listening for config changes', err); |
119 | }); | 121 | }); |
120 | } | 122 | } |
121 | }); | 123 | }); |