(options)
| 345 | } |
| 346 | |
| 347 | export async function waitForInstanceReady(options) { |
| 348 | const expectedPath = path.resolve(options.vaultPath); |
| 349 | const deadline = Date.now() + READY_TIMEOUT_MS; |
| 350 | let lastError = ""; |
| 351 | |
| 352 | while (Date.now() < deadline) { |
| 353 | try { |
| 354 | const { stdout } = await execObsidian(options, [ |
| 355 | `vault=${options.vaultName}`, |
| 356 | "vault", |
| 357 | "info=path", |
| 358 | ]); |
| 359 | const actualPath = path.resolve(stdout.trim()); |
| 360 | if (actualPath === expectedPath) return actualPath; |
| 361 | lastError = `resolved ${actualPath}, expected ${expectedPath}`; |
| 362 | } catch (error) { |
| 363 | lastError = error?.stderr?.trim() || error?.stdout?.trim() || error?.message || String(error); |
| 364 | } |
| 365 | await sleep(READY_INTERVAL_MS); |
| 366 | } |
| 367 | |
| 368 | throw new Error(`Obsidian instance did not become ready for ${options.vaultName}. Last error: ${lastError}`); |
| 369 | } |
| 370 | |
| 371 | export async function trustVaultAndVerifyQuickAdd(options) { |
| 372 | await execObsidian(options, [ |
no test coverage detected