MCPcopy
hub / github.com/marktext/marktext / constructor

Method constructor

packages/desktop/src/main/preferences/index.ts:36–63  ·  view source on GitHub ↗

* @param paths The path instance. * * NOTE: This throws an exception when validation fails.

(paths: AppPaths)

Source from the content-addressed store, hash-verified

34 * NOTE: This throws an exception when validation fails.
35 */
36 constructor(paths: AppPaths) {
37 // TODO: Preferences should not loaded if global.MARKTEXT_SAFE_MODE is set.
38 super()
39
40 const { preferencesPath } = paths
41 this.preferencesPath = preferencesPath
42 this.hasPreferencesFile = fs.existsSync(
43 path.join(this.preferencesPath, `./${PREFERENCES_FILE_NAME}.json`)
44 )
45 this.store = new Store({
46 // eslint-disable-next-line @typescript-eslint/no-explicit-any
47 schema: schema as any,
48 name: PREFERENCES_FILE_NAME,
49 migrations: {
50 '0.18.6': (store) => {
51 if (store.get('startUpAction') === 'lastState') {
52 store.set('startUpAction', 'openLastFolder')
53 }
54 }
55 },
56 beforeEachMigration: (_store, context) => {
57 log.info(`Preferences migration: ${context.fromVersion} -> ${context.toVersion}`)
58 }
59 })
60
61 this.staticPath = path.join(global.__static, 'preference.json')
62 this.init()
63 }
64
65 init = (): void => {
66 let defaultSettings: Record<string, unknown> | null = null

Callers

nothing calls this directly

Calls 3

joinMethod · 0.80
getMethod · 0.80
initMethod · 0.45

Tested by

no test coverage detected