-
-
Notifications
You must be signed in to change notification settings - Fork 61
Expand file tree
/
Copy pathsettings.ts
More file actions
17 lines (15 loc) · 649 Bytes
/
settings.ts
File metadata and controls
17 lines (15 loc) · 649 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import { defaultSettings, Settings } from '../src/appState/AppState'
import { readDataDirFile } from './dataDir'
export const loadSettings = async (): Promise<Settings> => {
const [data] = await readDataDirFile('settings.yaml')
return parseSettings(data)
}
const parseSettings = (data: Record<string, unknown> = {}): Settings => {
const { autoUpdateApp, extensions } = data
return {
autoUpdateApp: autoUpdateApp === undefined ? defaultSettings.autoUpdateApp : !!autoUpdateApp,
extensions: typeof extensions === 'object' && extensions !== null
? extensions as Record<string, boolean>
: defaultSettings.extensions
}
}