diff options
author | Shikanime Deva <shikalegend@gmail.com> | 2023-08-10 02:20:27 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-10 02:20:27 +0300 |
commit | 9e75db9a1dbcc245f94707c0917470143c17595b (patch) | |
tree | bc8d73cd6c7347ce10ced021cbda9ae9ce54bd81 /src | |
parent | f2594c5cc85e18450a31865f8387c8dc064006f2 (diff) |
Avoid unexpected shell expansion (#645)feature_node_1.2.1
* Avoid unexpected shell expansion
* Add install Node with ZSH as default test
* Fix LTS only work on >bionic
* Bump Node feature version
* Remove huge universal image on scenarios
Diffstat (limited to 'src')
-rw-r--r-- | src/node/devcontainer-feature.json | 4 | ||||
-rwxr-xr-x | src/node/install.sh | 24 |
2 files changed, 14 insertions, 14 deletions
diff --git a/src/node/devcontainer-feature.json b/src/node/devcontainer-feature.json index 9bf90b6..80bd912 100644 --- a/src/node/devcontainer-feature.json +++ b/src/node/devcontainer-feature.json @@ -1,6 +1,6 @@ { "id": "node", - "version": "1.2.0", + "version": "1.2.1", "name": "Node.js (via nvm), yarn and pnpm", "documentationURL": "https://github.com/devcontainers/features/tree/main/src/node", "description": "Installs Node.js, nvm, yarn, pnpm, and needed dependencies.", @@ -49,4 +49,4 @@ "installsAfter": [ "ghcr.io/devcontainers/features/common-utils" ] -} +}
\ No newline at end of file diff --git a/src/node/install.sh b/src/node/install.sh index 9048ac2..1ce8fee 100755 --- a/src/node/install.sh +++ b/src/node/install.sh @@ -9,7 +9,7 @@ export NODE_VERSION="${VERSION:-"lts"}" export NVM_VERSION="${NVMVERSION:-"0.39.2"}" -export NVM_DIR=${NVMINSTALLPATH:-"/usr/local/share/nvm"} +export NVM_DIR="${NVMINSTALLPATH:-"/usr/local/share/nvm"}" INSTALL_TOOLS_FOR_NODE_GYP="${NODEGYPDEPENDENCIES:-true}" # Comma-separated list of node versions to be installed (with nvm) @@ -118,10 +118,10 @@ set -e umask 0002 # Do not update profile - we'll do this manually export PROFILE=/dev/null -curl -so- https://raw.githubusercontent.com/nvm-sh/nvm/v${NVM_VERSION}/install.sh | bash -source ${NVM_DIR}/nvm.sh +curl -so- "https://raw.githubusercontent.com/nvm-sh/nvm/v${NVM_VERSION}/install.sh" | bash +source "${NVM_DIR}/nvm.sh" if [ "${NODE_VERSION}" != "" ]; then - nvm alias default ${NODE_VERSION} + nvm alias default "${NODE_VERSION}" fi EOF )" @@ -149,9 +149,9 @@ usermod -a -G nvm ${USERNAME} umask 0002 if [ ! -d "${NVM_DIR}" ]; then # Create nvm dir, and set sticky bit - mkdir -p ${NVM_DIR} - chown "${USERNAME}:nvm" ${NVM_DIR} - chmod g+rws ${NVM_DIR} + mkdir -p "${NVM_DIR}" + chown "${USERNAME}:nvm" "${NVM_DIR}" + chmod g+rws "${NVM_DIR}" su ${USERNAME} -c "${nvm_install_snippet}" 2>&1 # Update rc files if [ "${UPDATE_RC}" = "true" ]; then @@ -160,11 +160,11 @@ if [ ! -d "${NVM_DIR}" ]; then else echo "NVM already installed." if [ "${NODE_VERSION}" != "" ]; then - su ${USERNAME} -c "umask 0002 && . $NVM_DIR/nvm.sh && nvm install ${NODE_VERSION} && nvm alias default ${NODE_VERSION}" + su ${USERNAME} -c "umask 0002 && . '$NVM_DIR/nvm.sh' && nvm install '${NODE_VERSION}' && nvm alias default '${NODE_VERSION}'" fi fi -# Additional node versions to be installed but not be set as +# Additional node versions to be installed but not be set as # default we can assume the nvm is the group owner of the nvm # directory and the sticky bit on directories so any installed # files will have will have the correct ownership (nvm) @@ -173,12 +173,12 @@ if [ ! -z "${ADDITIONAL_VERSIONS}" ]; then IFS="," read -a additional_versions <<< "$ADDITIONAL_VERSIONS" for ver in "${additional_versions[@]}"; do - su ${USERNAME} -c "umask 0002 && . $NVM_DIR/nvm.sh && nvm install ${ver}" + su ${USERNAME} -c "umask 0002 && . '$NVM_DIR/nvm.sh' && nvm install '${ver}'" done # Ensure $NODE_VERSION is on the $PATH if [ "${NODE_VERSION}" != "" ]; then - su ${USERNAME} -c "umask 0002 && . $NVM_DIR/nvm.sh && nvm use default" + su ${USERNAME} -c "umask 0002 && . '$NVM_DIR/nvm.sh' && nvm use default" fi IFS=$OLDIFS fi @@ -218,7 +218,7 @@ fi # Clean up -su ${USERNAME} -c "umask 0002 && . $NVM_DIR/nvm.sh && nvm clear-cache" +su ${USERNAME} -c "umask 0002 && . '$NVM_DIR/nvm.sh' && nvm clear-cache" rm -rf /var/lib/apt/lists/* # Ensure privs are correct for installed node versions. Unfortunately the |