fix: daemon mode spawn path — closes #27 #30
Reference in New Issue
Block a user
Delete Branch "fix/daemon-spawn-path"
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
nerve start -ddaemon mode — child process was exiting immediately, making daemon mode completely non-functional.Why
runDaemon()usedfileURLToPath(import.meta.url)as the spawn script, which points tostart.js(the command module), notcli.js(the CLI entry). The child rannode start.js startwhich has no CLI routing logic and exits immediately.Changes
packages/cli/src/commands/start.ts: AddedcliEntryScript()function that resolves the correct CLI entry path (cli.js) viaprocess.argv[1],import.meta.url, or relative path fallback. Changedspawn()to use this resolved path.Verified
Ref
Closes #27
✅ LGTM
改动干净,逻辑正确。
cliEntryScript()的 fallback 链清晰:process.argv[1]→import.meta.url→ 相对路径推导,覆盖了 dev(.ts)和 prod(.js)两种场景。一个小建议(不 blocking):可以考虑加个
existsSync校验最终路径,万一推导错了能给个明确报错而不是 spawn 后静默退出。不过当前已经比之前好很多了。— 小橘 🍊(NEKO Team)
🔴 REQUEST CHANGES — 简化 cliEntryScript()
三级 fallback 过度防御了。
start.ts和cli.ts的相对位置是固定的(commands/start.ts→../cli.ts),不需要猜:多级 fallback 反而掩盖了真正的路径错误 — 如果算错了应该直接报错,而不是静默 fallback 到另一个可能也不对的路径。
— 小橘 🍊(NEKO Team)
🟡 还有一个问题
比之前好多了,
existsSync校验是对的 👍但第三个 candidate
here(fallback 到自身)需要去掉:前两个 candidate 已经覆盖了 bundled 和 source 两种场景。如果都没找到,应该直接 throw,这才是正确行为。去掉第三行就好。
— 小橘 🍊(NEKO Team)
3ecc271a52to85fa282d2e✅ APPROVED
两个改动都很干净:
start.ts — daemon spawn 路径修复
cliEntryScript()用 candidates fallback 找 CLI 入口,同时覆盖 bundled 和 source 两种场景 👍start.js当 spawn 入口确实会挂init.ts — git init 后自动 commit
git init→git add .→git commit让新 workspace 一开始就有 clean history,不再是 dirty state⚠️ 提醒:我们 PR #32 给 init.ts 的
buildWorkflowTemplate加了 export,但改的是第 127 行,和这里改的第 248 行不冲突。谁先合都行。— 小橘 🍊(NEKO Team)