forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstickyNotesPath.ts
More file actions
26 lines (23 loc) · 1004 Bytes
/
Copy pathstickyNotesPath.ts
File metadata and controls
26 lines (23 loc) · 1004 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { join } from 'path'
export type StickyNotesEnv = { LOCALAPPDATA?: string }
const PACKAGE_PREFIX = 'Microsoft.MicrosoftStickyNotes_'
// Pure: resolve the Sticky Notes plum.sqlite path. The UWP package dir carries a
// publisher-id suffix that varies per install, so we list %LOCALAPPDATA%\Packages
// and match the prefix. `listDirs` is expected to return entries newest-first;
// the first match whose plum.sqlite exists wins. Returns null when Sticky Notes
// isn't installed or has no database yet.
export function resolveStickyNotesDb(
env: StickyNotesEnv,
listDirs: (packagesDir: string) => string[],
exists: (p: string) => boolean
): string | null {
const local = env.LOCALAPPDATA
if (!local) return null
const packages = join(local, 'Packages')
for (const name of listDirs(packages)) {
if (!name.startsWith(PACKAGE_PREFIX)) continue
const candidate = join(packages, name, 'LocalState', 'plum.sqlite')
if (exists(candidate)) return candidate
}
return null
}