chore: Fix type errors from reverts.

This commit is contained in:
cpojer
2026-02-17 11:22:31 +09:00
parent 262b7a157a
commit 4b8f53979e
9 changed files with 30 additions and 22 deletions

View File

@@ -24,6 +24,15 @@ const multiselect = <T>(params: Parameters<typeof clackMultiselect<T>>[0]) =>
),
});
function guardPromptCancel<T>(value: T | symbol, runtime: RuntimeEnv): T {
if (isCancel(value)) {
cancel(stylePromptTitle("Model scan cancelled.") ?? "Model scan cancelled.");
runtime.exit(0);
throw new Error("unreachable");
}
return value;
}
const pad = (value: string, size: number) => value.padEnd(size);
const truncate = (value: string, max: number) => {
@@ -262,12 +271,7 @@ export async function modelsScanCommand(
initialValues: preselected,
});
if (isCancel(selection)) {
cancel(stylePromptTitle("Model scan cancelled.") ?? "Model scan cancelled.");
runtime.exit(0);
}
selected = selection;
selected = guardPromptCancel(selection, runtime);
if (imageSorted.length > 0) {
const imageSelection = await multiselect({
message: "Select image fallback models (ordered)",
@@ -279,12 +283,7 @@ export async function modelsScanCommand(
initialValues: imagePreselected,
});
if (isCancel(imageSelection)) {
cancel(stylePromptTitle("Model scan cancelled.") ?? "Model scan cancelled.");
runtime.exit(0);
}
selectedImages = imageSelection;
selectedImages = guardPromptCancel(imageSelection, runtime);
}
} else if (!process.stdin.isTTY && !opts.yes && !noInput && !opts.json) {
throw new Error("Non-interactive scan: pass --yes to apply defaults.");

View File

@@ -31,6 +31,7 @@ export function guardCancel<T>(value: T | symbol, runtime: RuntimeEnv): T {
if (isCancel(value)) {
cancel(stylePromptTitle("Setup cancelled.") ?? "Setup cancelled.");
runtime.exit(0);
throw new Error("unreachable");
}
return value;
}

View File

@@ -19,8 +19,8 @@ const NON_INTERACTIVE_DEFAULT_OPTIONS = {
export function createThrowingRuntime(): NonInteractiveRuntime {
return {
log: () => {},
error: (msg: string) => {
throw new Error(msg);
error: (...args: unknown[]) => {
throw new Error(args.map(String).join(" "));
},
exit: (code: number) => {
throw new Error(`exit:${code}`);