npm corepack fix
This commit is contained in:
parent
31c194978e
commit
143182e159
Binary file not shown.
|
|
@ -1043,9 +1043,40 @@ install_node_if_needed() {
|
|||
|
||||
ensure_pnpm_available() {
|
||||
export COREPACK_ENABLE_DOWNLOAD_PROMPT=0
|
||||
local pnpm_spec="${Z2M_PNPM_SPEC:-pnpm@10}"
|
||||
local archive=""
|
||||
local pkg_manager=""
|
||||
|
||||
if [ -f "${Z2M_STAGE_DIR}/zigbee2mqtt/package.json" ]; then
|
||||
pkg_manager="$(jq -r '.packageManager // empty' "${Z2M_STAGE_DIR}/zigbee2mqtt/package.json" 2>/dev/null || true)"
|
||||
elif [ -f "${Z2M_STAGE_DIR}/zigbee2mqtt.tar.gz" ]; then
|
||||
archive="${Z2M_STAGE_DIR}/zigbee2mqtt.tar.gz"
|
||||
pkg_manager="$(
|
||||
tar -xOf "$archive" --wildcards '*/package.json' 2>/dev/null \
|
||||
| jq -r '.packageManager // empty' 2>/dev/null \
|
||||
| head -n1 || true
|
||||
)"
|
||||
elif [ -f "${Z2M_STAGE_DIR}/zigbee2mqtt.tgz" ]; then
|
||||
archive="${Z2M_STAGE_DIR}/zigbee2mqtt.tgz"
|
||||
pkg_manager="$(
|
||||
tar -xOf "$archive" --wildcards '*/package.json' 2>/dev/null \
|
||||
| jq -r '.packageManager // empty' 2>/dev/null \
|
||||
| head -n1 || true
|
||||
)"
|
||||
fi
|
||||
|
||||
if [ -n "$pkg_manager" ] && printf '%s' "$pkg_manager" | grep -q '^pnpm@'; then
|
||||
pnpm_spec="$pkg_manager"
|
||||
fi
|
||||
|
||||
require_cmd corepack
|
||||
corepack enable || true
|
||||
pnpm -v >/dev/null 2>&1 || die "pnpm is not available after corepack enable"
|
||||
if ! pnpm -v >/dev/null 2>&1; then
|
||||
log "pnpm shim missing after corepack enable; activating ${pnpm_spec}"
|
||||
corepack prepare "$pnpm_spec" --activate || corepack install -g "$pnpm_spec" || npm install -g "$pnpm_spec"
|
||||
hash -r
|
||||
fi
|
||||
pnpm -v >/dev/null 2>&1 || die "pnpm is not available after corepack activation"
|
||||
log "pnpm version: $(pnpm -v)"
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue