()
| 51 | } |
| 52 | |
| 53 | function parseMainRoot(): string { |
| 54 | const args = process.argv.slice(2); |
| 55 | const i = args.indexOf('--main'); |
| 56 | if (i >= 0 && args[i + 1]) return path.resolve(args[i + 1]); |
| 57 | if (process.env.PARITY_MAIN) return path.resolve(process.env.PARITY_MAIN); |
| 58 | |
| 59 | // Default: discover the main worktree from git rather than hard-coding a path, so this runs on |
| 60 | // any OS and any checkout layout. Fail with an actionable message if it cannot be found. |
| 61 | const fromGit = findMainWorktree(); |
| 62 | if (fromGit && fs.existsSync(path.join(fromGit, 'src', 'core', 'parser.ts'))) return fromGit; |
| 63 | |
| 64 | throw new Error( |
| 65 | 'parse-parity: could not locate a main checkout to compare against. Pass --main <path>, set ' + |
| 66 | 'PARITY_MAIN, or add a worktree for the main branch (git worktree add <path> main).', |
| 67 | ); |
| 68 | } |
| 69 | |
| 70 | const mainRoot = parseMainRoot(); |
| 71 | const outDir = path.join(branchRoot, 'scripts', '.parity-out'); |
no test coverage detected