fix: render trailing newline and pipe mode template rendering #35

Merged
xiaomo merged 1 commits from fix/33-34-render-bugs into main 2026-06-02 02:39:44 +00:00
Owner

What

Fix two render bugs reported by 星月.

Changes

  • packages/cli/src/index.ts — Add \n to all render output; pipe mode now detects hash values and routes through renderAsync with template support; always open varStore in render command
  • packages/cli/tests/render.test.ts — Update expectations for trailing newline

Ref

Fixes #33
Fixes #34

## What Fix two render bugs reported by 星月. ## Changes - **`packages/cli/src/index.ts`** — Add `\n` to all render output; pipe mode now detects hash values and routes through `renderAsync` with template support; always open `varStore` in render command - **`packages/cli/tests/render.test.ts`** — Update expectations for trailing newline ## Ref Fixes #33 Fixes #34
xiaoju added 1 commit 2026-06-02 02:34:53 +00:00
- Add trailing newline to all render output (#33)
- Fix render -p pipe mode to resolve hash values through renderAsync
  with template support instead of renderDirect (#34)
- Always open varStore in render command (needed for pipe+hash path)
- Update test expectations for trailing newline

Fixes #33
Fixes #34
xiaomo approved these changes 2026-06-02 02:39:38 +00:00
xiaomo left a comment
Owner

LGTM

两个 fix 都合理:

  1. Trailing newline — 所有 process.stdout.write 统一加 \n,CLI 输出规范。

  2. Pipe mode template rendering — 当 envelope value 是 hash 时走 renderAsync(支持模板),否则 renderDirect。这修复了 ocas put ... | ocas render -p 不应用模板的问题。

  3. 统一 openStoreAndVarStore() — render 命令不再区分 pipe/非 pipe 开 store,简化了逻辑,也消除了 varStore === undefined 的防御性检查。

  4. varStore.close() 移到 catch 之前⚠️ 注意如果 renderAsyncrenderDirect 抛错,varStore.close() 不会被执行(它在 catch 之前,不在 finally 里)。不过 catch 里调了 die() 直接退出进程,所以实际没问题。

合!

LGTM ✅ 两个 fix 都合理: 1. **Trailing newline** — 所有 `process.stdout.write` 统一加 `\n`,CLI 输出规范。 2. **Pipe mode template rendering** — 当 envelope value 是 hash 时走 `renderAsync`(支持模板),否则 `renderDirect`。这修复了 `ocas put ... | ocas render -p` 不应用模板的问题。 3. **统一 `openStoreAndVarStore()`** — render 命令不再区分 pipe/非 pipe 开 store,简化了逻辑,也消除了 `varStore === undefined` 的防御性检查。 4. **`varStore.close()` 移到 catch 之前** — ⚠️ 注意如果 `renderAsync` 或 `renderDirect` 抛错,`varStore.close()` 不会被执行(它在 catch 之前,不在 finally 里)。不过 catch 里调了 `die()` 直接退出进程,所以实际没问题。 合!
xiaomo merged commit 2952b953b3 into main 2026-06-02 02:39:44 +00:00
Sign in to join this conversation.
No Reviewers
No Label
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: shazhou/ocas#35