()
| 58 | } |
| 59 | |
| 60 | function tryOpenDb(): SQLiteDatabase | null { |
| 61 | const dbPath = getDbPath(); |
| 62 | if (!existsSync(dbPath)) return null; |
| 63 | try { |
| 64 | const {DatabaseSync} = _require('node:sqlite') as { |
| 65 | DatabaseSync: new ( |
| 66 | path: string, |
| 67 | opts?: {readOnly?: boolean}, |
| 68 | ) => SQLiteDatabase; |
| 69 | }; |
| 70 | return new DatabaseSync(dbPath, {readOnly: true}); |
| 71 | } catch { |
| 72 | return null; |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | // ─── JSON helpers ───────────────────────────────────────────────────────────── |
| 77 |
no test coverage detected