Record npx path for deployment runtime
This commit is contained in:
@@ -264,17 +264,19 @@ build_frontend() {
|
||||
}
|
||||
|
||||
remember_node_runtime() {
|
||||
local npm_bin node_bin node_bin_dir tmp_file
|
||||
local npm_bin npx_bin node_bin node_bin_dir tmp_file
|
||||
npm_bin="$(resolve_npm_bin)"
|
||||
node_bin_dir="$(dirname "${npm_bin}")"
|
||||
export PATH="${node_bin_dir}:${PATH}"
|
||||
node_bin="$(PATH="${node_bin_dir}:${PATH}" command -v node || true)"
|
||||
npx_bin="$(PATH="${node_bin_dir}:${PATH}" command -v npx || true)"
|
||||
tmp_file="$(mktemp)"
|
||||
grep -v -E '^(# systemd 用户服务不会读取交互式 shell 配置|export CLAW_(NPM_BIN|NODE_BIN|NODE_BIN_DIR)=)' "${ENV_FILE}" >"${tmp_file}" || true
|
||||
grep -v -E '^(# systemd 用户服务不会读取交互式 shell 配置|export CLAW_(NPM_BIN|NPX_BIN|NODE_BIN|NODE_BIN_DIR)=)' "${ENV_FILE}" >"${tmp_file}" || true
|
||||
cat >>"${tmp_file}" <<EOF
|
||||
|
||||
# systemd 用户服务不会读取交互式 shell 配置,这里记录部署时可用的 Node.js/npm 路径。
|
||||
# systemd 用户服务不会读取交互式 shell 配置,这里记录部署时可用的 Node.js/npm/npx 路径。
|
||||
export CLAW_NPM_BIN=$(printf "%q" "${npm_bin}")
|
||||
export CLAW_NPX_BIN=$(printf "%q" "${npx_bin}")
|
||||
export CLAW_NODE_BIN=$(printf "%q" "${node_bin}")
|
||||
export CLAW_NODE_BIN_DIR=$(printf "%q" "${node_bin_dir}")
|
||||
EOF
|
||||
@@ -282,6 +284,7 @@ EOF
|
||||
rm -f "${tmp_file}"
|
||||
log "记录 Node.js 运行路径"
|
||||
echo "npm=${npm_bin}"
|
||||
echo "npx=${npx_bin:-未检测到}"
|
||||
echo "node=${node_bin:-未检测到}"
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ if [[ -n "${CLAW_NODE_BIN_DIR:-}" ]]; then
|
||||
export PATH="${CLAW_NODE_BIN_DIR}:${PATH}"
|
||||
fi
|
||||
export CLAW_NPM_BIN="${CLAW_NPM_BIN:-}"
|
||||
export CLAW_NPX_BIN="${CLAW_NPX_BIN:-}"
|
||||
export CLAW_NODE_BIN="${CLAW_NODE_BIN:-}"
|
||||
export CLAW_NODE_BIN_DIR="${CLAW_NODE_BIN_DIR:-}"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user