fix scoped npm modules

this fix tried so fix the npm function if using scoped modules like @vue/cli-services@latest
This commit is contained in:
Tobias 2025-05-05 18:43:03 +02:00 committed by GitHub
parent eeaed91d5d
commit ae8d1f2b70
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -55,10 +55,16 @@ install_node_and_modules() {
IFS=',' read -ra MODULES <<<"$NODE_MODULE" IFS=',' read -ra MODULES <<<"$NODE_MODULE"
for mod in "${MODULES[@]}"; do for mod in "${MODULES[@]}"; do
local MODULE_NAME MODULE_REQ_VERSION MODULE_INSTALLED_VERSION local MODULE_NAME MODULE_REQ_VERSION MODULE_INSTALLED_VERSION
if [[ "$mod" == *"@"* ]]; then if [[ "$mod" == @*/*@* ]]; then
# Scoped package with version, e.g. @vue/cli-service@latest
MODULE_NAME="${mod%@*}" MODULE_NAME="${mod%@*}"
MODULE_REQ_VERSION="${mod#*@}" MODULE_REQ_VERSION="${mod##*@}"
elif [[ "$mod" == *"@"* ]]; then
# Unscoped package with version, e.g. yarn@latest
MODULE_NAME="${mod%@*}"
MODULE_REQ_VERSION="${mod##*@}"
else else
# No version specified
MODULE_NAME="$mod" MODULE_NAME="$mod"
MODULE_REQ_VERSION="latest" MODULE_REQ_VERSION="latest"
fi fi