refactor: extract validateCount, replace CLI spawn with direct import
CI / check (pull_request) Successful in 2m24s

- Extract validateCount() from cmdThreadExec (throw instead of process.exit)
- 5 validation tests now import validateCount directly (no subprocess)
- Only --help tests still spawn CLI (need Commander output)
- Test time: 1.7s → 475ms

Fixes #61
This commit is contained in:
2026-06-04 12:31:17 +00:00
parent 1ce0b9b9ee
commit 18170a4313
2 changed files with 32 additions and 32 deletions
+7 -3
View File
@@ -1128,6 +1128,12 @@ export async function cmdThreadResume(
});
}
export function validateCount(count: number): void {
if (count < 1 || !Number.isInteger(count)) {
throw new Error(`--count must be a positive integer, got: ${count}`);
}
}
export async function cmdThreadExec(
storageRoot: string,
threadId: ThreadId,
@@ -1136,9 +1142,7 @@ export async function cmdThreadExec(
background: boolean,
backgroundWorker: boolean,
): Promise<StepOutput[]> {
if (count < 1 || !Number.isInteger(count)) {
fail(`--count must be a positive integer, got: ${count}`);
}
validateCount(count);
// Check if thread is already running in background (unless we ARE the background worker)
if (!backgroundWorker) {