Skip to content

Commit c103184

Browse files
committed
Remove hardcoded node lts version from test scripts
1 parent 97d81bd commit c103184

2 files changed

Lines changed: 23 additions & 6 deletions

File tree

test/node/install_additional_node.sh

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,20 @@ set -e
55
# Optional: Import test library
66
source dev-container-features-test-lib
77

8-
# 'lts' is now some version of node 20...
9-
check "version_on_path" node -v | grep 20
8+
# Install jq if not already installed
9+
if ! type jq >/dev/null 2>&1; then
10+
apt-get update && apt-get install -y jq
11+
fi
12+
13+
#Get the latest LTS version of Node.js
14+
LATEST_LTS_VERSION=$(curl -s https://nodejs.org/dist/index.json | jq -r '[.[] | select(.lts != false)][0].version')
15+
16+
17+
# 'lts' is fetched instead of hardcoded to a specific version
18+
check "version_on_path" node -v | grep "$LATEST_LTS_VERSION"
1019
check "pnpm" bash -c "pnpm -v | grep 8.8.0"
1120

12-
check "v20_installed" ls -1 /usr/local/share/nvm/versions/node | grep 20
21+
check "lts_installed" ls -1 /usr/local/share/nvm/versions/node | grep "$LATEST_LTS_VERSION"
1322
check "v14_installed" ls -1 /usr/local/share/nvm/versions/node | grep 14.19.3
1423
check "v17_installed" ls -1 /usr/local/share/nvm/versions/node | grep 17.9.1
1524

test/node/install_additional_node_on_rhel_family.sh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,19 @@ set -e
55
# Optional: Import test library
66
source dev-container-features-test-lib
77

8-
# 'lts' is now some version of node 20...
9-
check "version_on_path" node -v | grep 20
8+
# Install jq if not already installed
9+
if ! type jq >/dev/null 2>&1; then
10+
yum install -y jq
11+
fi
12+
13+
#Get the latest LTS version of Node.js
14+
LATEST_LTS_VERSION=$(curl -s https://nodejs.org/dist/index.json | jq -r '[.[] | select(.lts != false)][0].version')
15+
16+
# 'lts' is fetched instead of hardcoded to a specific version
17+
check "version_on_path" node -v | grep "$LATEST_LTS_VERSION"
1018
check "pnpm" bash -c "pnpm -v | grep 6.16.0"
1119

12-
check "v20_installed" ls -1 /usr/local/share/nvm/versions/node | grep 20
20+
check "lts_installed" ls -1 /usr/local/share/nvm/versions/node | grep "$LATEST_LTS_VERSION"
1321
check "v14_installed" ls -1 /usr/local/share/nvm/versions/node | grep 14.19.3
1422
check "v17_installed" ls -1 /usr/local/share/nvm/versions/node | grep 17.9.1
1523

0 commit comments

Comments
 (0)