aboutsummaryrefslogtreecommitdiff
path: root/src/node
diff options
context:
space:
mode:
Diffstat (limited to 'src/node')
-rw-r--r--src/node/devcontainer-feature.json6
-rw-r--r--src/node/install.sh25
2 files changed, 25 insertions, 6 deletions
diff --git a/src/node/devcontainer-feature.json b/src/node/devcontainer-feature.json
index ebce21b..52715fd 100644
--- a/src/node/devcontainer-feature.json
+++ b/src/node/devcontainer-feature.json
@@ -34,9 +34,5 @@
"NVM_DIR": "/usr/local/share/nvm",
"NVM_SYMLINK_CURRENT": "true",
"PATH": "${NVM_DIR}/current/bin:${PATH}"
- },
- "install": {
- "app": "",
- "file": "install.sh"
}
-} \ No newline at end of file
+}
diff --git a/src/node/install.sh b/src/node/install.sh
index b846007..7169919 100644
--- a/src/node/install.sh
+++ b/src/node/install.sh
@@ -11,6 +11,10 @@ export NODE_VERSION=${VERSION:-"lts"}
export NVM_DIR=${NVM_INSTALL_PATH:-"/usr/local/share/nvm"}
INSTALL_TOOLS_FOR_NODE_GYP="${INSTALL_TOOLS_FOR_NODE_GYP:-true}"
+# Comma-separated list of node versions to be installed (with nvm)
+# alongside NODE_VERSION, but not set as default.
+ADDITIONAL_VERSIONS=${ADDITIONAL_VERSIONS:-""}
+
USERNAME=${USERNAME:-"automatic"}
UPDATE_RC=${UPDATE_RC:-"true"}
@@ -133,7 +137,7 @@ su ${USERNAME} -c "$(cat << EOF
if [ "${NODE_VERSION}" != "" ]; then
nvm alias default ${NODE_VERSION}
fi
- nvm clear-cache
+ nvm clear-cache
EOF
)" 2>&1
# Update rc files
@@ -146,6 +150,25 @@ EOF
)"
fi
+# Additional node versions to be installed but not be set as default.
+if [ ! -z "${ADDITIONAL_VERSIONS}" ]; then
+
+ OLDIFS=$IFS
+ IFS=","
+ read -a additional_versions <<< "$ADDITIONAL_VERSIONS"
+ for ver in "${additional_versions[@]}"; do
+ su ${USERNAME} -c ". $NVM_DIR/nvm.sh && nvm install ${ver}"
+ su ${USERNAME} -c ". $NVM_DIR/nvm.sh && nvm clear-cache"
+ # Reset the NODE_VERSION as the default version on the path.
+ done
+
+ # Ensure $NODE_VERSION is on the $PATH
+ if [ "${NODE_VERSION}" != "" ]; then
+ su ${USERNAME} -c ". $NVM_DIR/nvm.sh && nvm use default"
+ fi
+ IFS=$OLDIFS
+fi
+
# If enabled, verify "python3", "make", "gcc", "g++" commands are available so node-gyp works - https://github.com/nodejs/node-gyp
if [ "${INSTALL_TOOLS_FOR_NODE_GYP}" = "true" ]; then
echo "Verifying node-gyp OS requirements..."