| 76 | } |
| 77 | |
| 78 | function parseArgs(argv) { |
| 79 | let scope = "all"; |
| 80 | let filter = null; |
| 81 | |
| 82 | for (let i = 0; i < argv.length; i++) { |
| 83 | const a = argv[i]; |
| 84 | if (a === "--scope") { |
| 85 | const v = argv[i + 1]; |
| 86 | if (v === "all" || v === "scripts" || v === "packages") { |
| 87 | scope = v; |
| 88 | i++; |
| 89 | continue; |
| 90 | } |
| 91 | throw new Error(`run-tests: invalid --scope value: ${String(v)}`); |
| 92 | } |
| 93 | |
| 94 | if (a === "--filter") { |
| 95 | const v = argv[i + 1]; |
| 96 | if (typeof v !== "string" || v.trim().length === 0 || v.startsWith("--")) { |
| 97 | throw new Error("run-tests: --filter requires a non-empty pattern string"); |
| 98 | } |
| 99 | filter = v; |
| 100 | i++; |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | return { scope, filter }; |
| 105 | } |
| 106 | |
| 107 | const root = process.cwd(); |
| 108 | const { scope, filter } = parseArgs(process.argv.slice(2)); |