()
| 60 | * @throws {ViewerMissingError} when no candidate contains an `index.html`. |
| 61 | */ |
| 62 | export function resolveViewerDir(): string { |
| 63 | const candidates = viewerDirCandidates(); |
| 64 | for (const dir of candidates) { |
| 65 | try { |
| 66 | if (fs.statSync(path.join(dir, 'index.html')).isFile()) { |
| 67 | // realpath so the containment checks in `security.ts` compare like for |
| 68 | // like when the install lives behind a symlink (Homebrew, nvm, pnpm). |
| 69 | return fs.realpathSync(dir); |
| 70 | } |
| 71 | } catch { |
| 72 | // Not here — try the next candidate. |
| 73 | } |
| 74 | } |
| 75 | throw new ViewerMissingError(candidates); |
| 76 | } |
no test coverage detected