fix: 5 critical bugs from Codex review

1. Windows: change "node npm.cmd" to "call npm.cmd" (npm.cmd is a
   batch wrapper, not a JS file — can't run with node.exe)
2. Build: use pnpm instead of npm (upstream build script calls pnpm
   subcommands that fail without it); add set -eo pipefail
3. Build: fail explicitly when dist/ not generated instead of || true
4. Run scripts: separate first-time onboard from normal startup
   (was running onboard every time, blocking normal launch)
5. Windows .bat: fix findstr patterns for .env dedup with /r flag
This commit is contained in:
dongsheng123132
2026-03-09 11:02:14 +08:00
parent 1b4bfb38d9
commit c556f36d92
5 changed files with 74 additions and 35 deletions

16
uclaw-scripts/启动菜单.command Normal file → Executable file
View File

@@ -122,7 +122,11 @@ ensure_deps() {
if [ ! -d "$OPENCLAW_DIR/dist" ]; then
echo -e " ${YELLOW}正在构建...${NC}"
cd "$OPENCLAW_DIR"
"$NODE_BIN" "$NPM_BIN" run build 2>&1 || true
"$NODE_BIN" "$NPM_BIN" run build 2>&1
if [ ! -d "$OPENCLAW_DIR/dist" ]; then
echo -e " ${RED}构建失败!请检查上方错误信息${NC}"
return 1
fi
echo -e " ${GREEN}构建完成${NC}"
fi
}
@@ -166,9 +170,13 @@ do_run() {
echo ""
ensure_deps
cd "$OPENCLAW_DIR"
"$NODE_BIN" openclaw.mjs onboard --install-daemon 2>&1 || \
"$NODE_BIN" openclaw.mjs 2>&1 || \
"$NODE_BIN" "$NPM_BIN" start 2>&1
# 首次运行走 onboard之后直接启动
if [ ! -f "$HOME/.openclaw/openclaw.json" ]; then
echo -e " ${YELLOW}首次配置...${NC}"
"$NODE_BIN" openclaw.mjs onboard --install-daemon 2>&1
fi
echo -e " ${CYAN}启动 OpenClaw 服务...${NC}"
"$NODE_BIN" openclaw.mjs 2>&1 || "$NODE_BIN" "$NPM_BIN" start 2>&1
}
# [5] 配置国产模型