fix: render trailing newline and pipe mode template rendering #35
Reference in New Issue
Block a user
Delete Branch "fix/33-34-render-bugs"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Fix two render bugs reported by 星月.
Changes
packages/cli/src/index.ts— Add\nto all render output; pipe mode now detects hash values and routes throughrenderAsyncwith template support; always openvarStorein render commandpackages/cli/tests/render.test.ts— Update expectations for trailing newlineRef
Fixes #33
Fixes #34
LGTM ✅
两个 fix 都合理:
Trailing newline — 所有
process.stdout.write统一加\n,CLI 输出规范。Pipe mode template rendering — 当 envelope value 是 hash 时走
renderAsync(支持模板),否则renderDirect。这修复了ocas put ... | ocas render -p不应用模板的问题。统一
openStoreAndVarStore()— render 命令不再区分 pipe/非 pipe 开 store,简化了逻辑,也消除了varStore === undefined的防御性检查。varStore.close()移到 catch 之前 — ⚠️ 注意如果renderAsync或renderDirect抛错,varStore.close()不会被执行(它在 catch 之前,不在 finally 里)。不过 catch 里调了die()直接退出进程,所以实际没问题。合!