Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/node/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "node",
"version": "1.4.0",
"version": "1.4.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.",
Expand Down
7 changes: 5 additions & 2 deletions src/node/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,11 @@ 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

curl -so- "https://raw.githubusercontent.com/nvm-sh/nvm/v${NVM_VERSION}/install.sh" | bash || {
PREV_NVM_VERSION=$(curl -s https://api.github.com/repos/nvm-sh/nvm/releases/latest | grep '"tag_name"' | sed -E 's/.*"([^"]+)".*/\1/')
Comment thread
samruddhikhandale marked this conversation as resolved.
curl -so- "https://raw.githubusercontent.com/nvm-sh/nvm/\${PREV_NVM_VERSION}/install.sh" | bash
NVM_VERSION="\${PREV_NVM_VERSION}"
}
Comment thread
samruddhikhandale marked this conversation as resolved.
source "${NVM_DIR}/nvm.sh"
if [ "${NODE_VERSION}" != "" ]; then
nvm alias default "${NODE_VERSION}"
Expand Down
27 changes: 27 additions & 0 deletions test/node/nvm_test_fallback.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

set -e

# Optional: Import test library
source dev-container-features-test-lib

set -e

trap 'echo "Error occurred at line $LINENO"; exit 1' ERR
source /usr/local/share/nvm/nvm.sh
#check nvm version
echo -e "\n✅ nvm version as installed by feature = v$(nvm --version)";
NVM_DIR="/usr/local/share/nvm"
NODE_VERSION="lts"
FAKE_NVM_VERSION="1.2.XYZ"
curl -so- "https://raw.githubusercontent.com/nvm-sh/nvm/v${FAKE_NVM_VERSION}/install.sh" | bash || {
PREV_NVM_VERSION=$(curl -s https://api.github.com/repos/nvm-sh/nvm/releases/latest | grep '"tag_name"' | sed -E 's/.*"([^"]+)".*/\1/')
curl -so- "https://raw.githubusercontent.com/nvm-sh/nvm/${PREV_NVM_VERSION}/install.sh" | bash
NVM_VERSION="${PREV_NVM_VERSION}"
}

#check nvm version
echo -e "\n✅ nvm version as installed by test = v$(nvm --version)";

# Report result
reportResults
8 changes: 8 additions & 0 deletions test/node/scenarios.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
{
"nvm_test_fallback": {
"image": "debian:11",
"features": {
"node": {
"version": "lts"
}
}
},
"install_additional_node": {
"image": "debian:11",
"features": {
Expand Down