(args: string[])
| 367 | } |
| 368 | |
| 369 | async function parseArgs(args: string[]): Promise<CompareOptions> { |
| 370 | const packageVersion = await readPackageVersion(); |
| 371 | const options: CompareOptions = { |
| 372 | releaseDir: releaseBenchmarkDir(), |
| 373 | version: packageVersion, |
| 374 | }; |
| 375 | |
| 376 | for (let index = 0; index < args.length; index += 1) { |
| 377 | const arg = args[index]!; |
| 378 | |
| 379 | if (arg === "--release-dir") { |
| 380 | options.releaseDir = path.resolve(readArgValue(args, index)); |
| 381 | index += 1; |
| 382 | continue; |
| 383 | } |
| 384 | |
| 385 | if (arg === "--version") { |
| 386 | options.version = readArgValue(args, index); |
| 387 | index += 1; |
| 388 | continue; |
| 389 | } |
| 390 | |
| 391 | if (arg === "--head") { |
| 392 | options.head = path.resolve(readArgValue(args, index)); |
| 393 | index += 1; |
| 394 | continue; |
| 395 | } |
| 396 | |
| 397 | if (arg === "--base") { |
| 398 | options.base = path.resolve(readArgValue(args, index)); |
| 399 | index += 1; |
| 400 | continue; |
| 401 | } |
| 402 | |
| 403 | if (arg === "--out") { |
| 404 | options.out = path.resolve(readArgValue(args, index)); |
| 405 | index += 1; |
| 406 | continue; |
| 407 | } |
| 408 | |
| 409 | if (arg === "--summary") { |
| 410 | options.summary = path.resolve(readArgValue(args, index)); |
| 411 | index += 1; |
| 412 | continue; |
| 413 | } |
| 414 | |
| 415 | throw new Error(`Unknown release benchmark comparison argument: ${arg}`); |
| 416 | } |
| 417 | |
| 418 | parseReleaseVersion(options.version); |
| 419 | return options; |
| 420 | } |
| 421 | |
| 422 | /** Run the release benchmark comparison CLI. */ |
| 423 | export async function main(args = Bun.argv.slice(2)) { |
no test coverage detected