refactor(update-cli): share timeout option validation

This commit is contained in:
Peter Steinberger
2026-02-18 22:49:15 +00:00
parent b704bad8f3
commit 61c0c147ad
5 changed files with 42 additions and 14 deletions

View File

@@ -14,6 +14,7 @@ import { pathExists } from "../../utils.js";
import {
isEmptyDir,
isGitCheckout,
parseTimeoutMsOrExit,
resolveGitInstallDir,
resolveUpdateRoot,
type UpdateWizardOptions,
@@ -29,10 +30,8 @@ export async function updateWizardCommand(opts: UpdateWizardOptions = {}): Promi
return;
}
const timeoutMs = opts.timeout ? Number.parseInt(opts.timeout, 10) * 1000 : undefined;
if (timeoutMs !== undefined && (Number.isNaN(timeoutMs) || timeoutMs <= 0)) {
defaultRuntime.error("--timeout must be a positive integer (seconds)");
defaultRuntime.exit(1);
const timeoutMs = parseTimeoutMsOrExit(opts.timeout);
if (timeoutMs === null) {
return;
}