@@ -11,6 +11,7 @@ import {
|
11 | 11 | renderGroupedTestComparison, |
12 | 12 | renderGroupedTestReport, |
13 | 13 | } from "./lib/test-group-report.mjs"; |
| 14 | +import { parsePositiveInt } from "./lib/numeric-options.mjs"; |
14 | 15 | import { formatMs } from "./lib/vitest-report-cli-utils.mjs"; |
15 | 16 | import { resolveVitestNodeArgs } from "./run-vitest.mjs"; |
16 | 17 | import { |
@@ -55,11 +56,6 @@ function usage() {
|
55 | 56 | ].join("\n"); |
56 | 57 | } |
57 | 58 | |
58 | | -function parsePositiveInt(value, fallback) { |
59 | | -const parsed = Number.parseInt(value ?? "", 10); |
60 | | -return Number.isFinite(parsed) && parsed > 0 ? parsed : fallback; |
61 | | -} |
62 | | - |
63 | 59 | export function parseTestGroupReportArgs(argv) { |
64 | 60 | const args = { |
65 | 61 | allowFailures: false, |
@@ -130,32 +126,32 @@ export function parseTestGroupReportArgs(argv) {
|
130 | 126 | continue; |
131 | 127 | } |
132 | 128 | if (arg === "--limit") { |
133 | | -args.limit = parsePositiveInt(argv[index + 1], args.limit); |
| 129 | +args.limit = parsePositiveInt(argv[index + 1], "--limit"); |
134 | 130 | index += 1; |
135 | 131 | continue; |
136 | 132 | } |
137 | 133 | if (arg === "--max-test-ms") { |
138 | | -args.maxTestMs = parsePositiveInt(argv[index + 1], args.maxTestMs); |
| 134 | +args.maxTestMs = parsePositiveInt(argv[index + 1], "--max-test-ms"); |
139 | 135 | index += 1; |
140 | 136 | continue; |
141 | 137 | } |
142 | 138 | if (arg === "--timeout-ms") { |
143 | | -args.timeoutMs = parsePositiveInt(argv[index + 1], args.timeoutMs); |
| 139 | +args.timeoutMs = parsePositiveInt(argv[index + 1], "--timeout-ms"); |
144 | 140 | index += 1; |
145 | 141 | continue; |
146 | 142 | } |
147 | 143 | if (arg === "--kill-grace-ms") { |
148 | | -args.killGraceMs = parsePositiveInt(argv[index + 1], args.killGraceMs); |
| 144 | +args.killGraceMs = parsePositiveInt(argv[index + 1], "--kill-grace-ms"); |
149 | 145 | index += 1; |
150 | 146 | continue; |
151 | 147 | } |
152 | 148 | if (arg === "--concurrency") { |
153 | | -args.concurrency = parsePositiveInt(argv[index + 1], args.concurrency); |
| 149 | +args.concurrency = parsePositiveInt(argv[index + 1], "--concurrency"); |
154 | 150 | index += 1; |
155 | 151 | continue; |
156 | 152 | } |
157 | 153 | if (arg === "--top-files") { |
158 | | -args.topFiles = parsePositiveInt(argv[index + 1], args.topFiles); |
| 154 | +args.topFiles = parsePositiveInt(argv[index + 1], "--top-files"); |
159 | 155 | index += 1; |
160 | 156 | continue; |
161 | 157 | } |
|