ci: updated base-image

This commit is contained in:
Marvin Zhang
2024-11-20 14:42:15 +08:00
parent 874f02a9fe
commit 6babe327b4
2 changed files with 65 additions and 25 deletions

View File

@@ -1,23 +1,25 @@
#!/bin/bash
version="22"
# installs nvm (Node Version Manager)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash
# download and install Node.js (you may need to restart the terminal)
nvm install 22
# ensure changes take effect immediately
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
# set node version
nvm use 22
# download and install Node.js (you may need to restart the terminal)
nvm install ${version}
# set node version and make it the default
nvm use ${version}
nvm alias default ${version}
# verifies the right Node.js version is in the environment
if [[ ! "$(node -v)" =~ ^v22 ]]; then
echo "Node.js version is not v22.x"
exit 1
fi
# verifies the right npm version is in the environment
if [[ ! "$(npm -v)" =~ ^10 ]]; then
echo "npm version is not 10.x"
if [[ ! "$(node -v)" =~ ^v${version} ]]; then
echo "Node.js version is not v${version}.x"
exit 1
fi