MCPcopy Create free account
hub / github.com/modem-dev/hunk / parseRunReleaseBenchmarkArgs

Function parseRunReleaseBenchmarkArgs

scripts/run-release-benchmark.ts:28–72  ·  view source on GitHub ↗
(
  args: string[],
)

Source from the content-addressed store, hash-verified

26
27/** Parse release benchmark CLI options while preserving explicit output paths. */
28export async function parseRunReleaseBenchmarkArgs(
29 args: string[],
30): Promise<RunReleaseBenchmarkOptions> {
31 const version = await readPackageVersion(repoRoot);
32 const options: RunReleaseBenchmarkOptions = {
33 version,
34 samples: Number(process.env.HUNK_RELEASE_BENCHMARK_SAMPLES ?? 5),
35 out: releaseBenchmarkPath(version, releaseBenchmarkDir(repoRoot)),
36 };
37 let outExplicitlySet = false;
38
39 for (let index = 0; index < args.length; index += 1) {
40 const arg = args[index]!;
41
42 if (arg === "--version") {
43 options.version = readArgValue(args, index);
44 if (!outExplicitlySet) {
45 options.out = releaseBenchmarkPath(options.version, releaseBenchmarkDir(repoRoot));
46 }
47 index += 1;
48 continue;
49 }
50
51 if (arg === "--samples") {
52 options.samples = Number(readArgValue(args, index));
53 index += 1;
54 continue;
55 }
56
57 if (arg === "--out") {
58 options.out = path.resolve(readArgValue(args, index));
59 outExplicitlySet = true;
60 index += 1;
61 continue;
62 }
63
64 throw new Error(`Unknown release benchmark argument: ${arg}`);
65 }
66
67 if (!Number.isFinite(options.samples) || options.samples < 1) {
68 throw new Error("--samples must be a positive number");
69 }
70
71 return options;
72}
73
74/** Run the default benchmark suite and write the versioned release snapshot. */
75export async function main(args = Bun.argv.slice(2)) {

Callers 2

mainFunction · 0.85

Calls 4

readPackageVersionFunction · 0.90
releaseBenchmarkPathFunction · 0.90
releaseBenchmarkDirFunction · 0.90
readArgValueFunction · 0.70

Tested by

no test coverage detected