()
| 13 | import { fileURLToPath } from "node:url"; |
| 14 | |
| 15 | export function repoRoot(): string { |
| 16 | const override = process.env.HYPERFRAMES_REPO_ROOT; |
| 17 | if (override && existsSync(resolve(override, "packages", "aws-lambda", "package.json"))) { |
| 18 | return override; |
| 19 | } |
| 20 | let dir = dirname(fileURLToPath(import.meta.url)); |
| 21 | for (let depth = 0; depth < 12; depth++) { |
| 22 | if (existsSync(resolve(dir, "packages", "aws-lambda", "package.json"))) { |
| 23 | return dir; |
| 24 | } |
| 25 | const parent = dirname(dir); |
| 26 | if (parent === dir) break; |
| 27 | dir = parent; |
| 28 | } |
| 29 | throw new Error( |
| 30 | "[hyperframes lambda] could not find the repo root (no packages/aws-lambda/ above this CLI's source). " + |
| 31 | "Run `hyperframes lambda` from within a hyperframes checkout, or set HYPERFRAMES_REPO_ROOT explicitly.", |
| 32 | ); |
| 33 | } |
no test coverage detected