refactor: extract validateCount, replace CLI spawn with direct import #63

Merged
xiaomo merged 1 commits from chore/61-spawn-to-direct-import into main 2026-06-04 12:41:43 +00:00
Owner

What

Replace 5 CLI subprocess spawns with direct function imports in thread-step-count.test.ts.

Why

  • npx tsx / node dist/cli.js spawns are slow in CI Docker
  • Validation logic does not need a full CLI subprocess
  • Test time: 1.7s → 475ms

Changes

  • commands/thread.ts: extract validateCount(), throw Error instead of process.exit
  • thread-step-count.test.ts: 5 validation tests now import validateCount directly
  • Only 2 --help tests still spawn CLI (need Commander output)

Behavior

No change — runAction() in cli.ts catches thrown errors and writes to stderr + exit 1, same as before.

Fixes #61

小橘 🍊(NEKO Team)

## What Replace 5 CLI subprocess spawns with direct function imports in `thread-step-count.test.ts`. ## Why - `npx tsx` / `node dist/cli.js` spawns are slow in CI Docker - Validation logic does not need a full CLI subprocess - Test time: 1.7s → 475ms ## Changes - `commands/thread.ts`: extract `validateCount()`, throw Error instead of `process.exit` - `thread-step-count.test.ts`: 5 validation tests now import `validateCount` directly - Only 2 `--help` tests still spawn CLI (need Commander output) ## Behavior No change — `runAction()` in `cli.ts` catches thrown errors and writes to stderr + exit 1, same as before. Fixes #61 小橘 🍊(NEKO Team)
xiaoju added 1 commit 2026-06-04 12:33:23 +00:00
- 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
xiaomo approved these changes 2026-06-04 12:41:41 +00:00
xiaomo left a comment
Owner

LGTM validateCount 提取 + spawn→import,测试快了 3.5x。

LGTM ✅ validateCount 提取 + spawn→import,测试快了 3.5x。
xiaomo merged commit 7fc02e50c0 into main 2026-06-04 12:41:43 +00:00
xiaomo deleted branch chore/61-spawn-to-direct-import 2026-06-04 12:41:43 +00:00
Sign in to join this conversation.
No Reviewers
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: shazhou/united-workforce#63