fix: cas has now returns exit 1 for non-existent hashes #482

Merged
xiaoju merged 1 commits from fix/481-cas-has-exit-code into main 2026-05-25 01:18:08 +00:00
Owner

What

Changed the exit behavior of uwf cas has to return exit code 1 when a hash doesn't exist.

Why

This enables proper use in shell conditionals like if uwf cas has $HASH; then ..., which is the expected behavior for boolean check commands in Unix/Linux environments.

Changes

  • Modified packages/cli-workflow/src/cli.ts to exit with code 1 when hash doesn't exist
  • Preserved JSON output {exists:false} for programmatic consumption
  • Added comprehensive test suite in cas-exit-code.test.ts to verify exit codes
  • Added general CAS tests in cas.test.ts for command validation

Ref

Fixes #481

## What Changed the exit behavior of `uwf cas has` to return exit code 1 when a hash doesn't exist. ## Why This enables proper use in shell conditionals like `if uwf cas has $HASH; then ...`, which is the expected behavior for boolean check commands in Unix/Linux environments. ## Changes - Modified `packages/cli-workflow/src/cli.ts` to exit with code 1 when hash doesn't exist - Preserved JSON output `{exists:false}` for programmatic consumption - Added comprehensive test suite in `cas-exit-code.test.ts` to verify exit codes - Added general CAS tests in `cas.test.ts` for command validation ## Ref Fixes #481
xiaoju added 1 commit 2026-05-25 00:48:34 +00:00
Changed the exit behavior of 'uwf cas has' to return exit code 1 when
a hash doesn't exist, while preserving the JSON output {exists:false}.
This enables proper use in shell conditionals like 'if uwf cas has $HASH'.

Fixes #481
xiaoju reviewed 2026-05-25 00:54:04 +00:00
xiaoju left a comment
Author
Owner

Code Review — 小橘 🍊

Verdict: Approved

  • 核心改动精简(4行),先 writeOutput 再 process.exit(1),逻辑正确
  • 14 个测试覆盖全面(单元6 + 集成8,含边界/YAML/回归)
  • JSON 输出不变,仅改 exit code,向后兼容

LGTM,可以合并 🍊

## Code Review — 小橘 🍊 **Verdict: Approved** ✅ - 核心改动精简(4行),先 writeOutput 再 process.exit(1),逻辑正确 - 14 个测试覆盖全面(单元6 + 集成8,含边界/YAML/回归) - JSON 输出不变,仅改 exit code,向后兼容 LGTM,可以合并 🍊
xiaoju merged commit 1ec32ae0fd into main 2026-05-25 01:18:08 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: uncaged/workflow#482