Merge pull request #4621 from continuedev/pe/nvm-warning

feat: check for `nvm` version in install script
This commit is contained in:
Dallin Romney 2025-03-12 17:33:52 -07:00 • committed by GitHub
commit 2e5a8ce004
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 47 additions and 0 deletions

View file

@ -25,6 +25,31 @@ if ($null -eq $node) {
& node --version
}
# Node.js version check
if (Test-Path ".nvmrc") {
$requiredNodeVersion = Get-Content ".nvmrc"
$currentNodeVersion = node -v
# Remove 'v' prefix from versions for comparison
$requiredVersion = $requiredNodeVersion.TrimStart('v')
$currentVersion = $currentNodeVersion.TrimStart('v')
if ($requiredVersion -ne $currentVersion) {
Write-Host "`n⚠️ Warning: Your Node.js version ($currentNodeVersion) does not match the required version ($requiredNodeVersion)" -ForegroundColor Yellow
Write-Host "Please consider switching to the correct version using: nvm use" -ForegroundColor Yellow
# Check if running in interactive mode
if ([Environment]::UserInteractive -and [Environment]::GetCommandLineArgs().Count -eq 0) {
Write-Host "Press Enter to continue with installation anyway..." -NoNewline -ForegroundColor Yellow
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
Write-Host "`n" # Add newline after key press
} else {
Write-Host "Continuing with installation anyway...`n" -ForegroundColor Yellow
}
}
}
# if ($null -eq $cargo) {
# Write-Host "`n...`n"
# Write-Host "Cargo`n" -ForegroundColor White

View file

@ -5,6 +5,28 @@
# - Debug -> Extension
set -e
# Check if node version matches .nvmrc
if [ -f .nvmrc ]; then
required_node_version=$(cat .nvmrc)
current_node_version=$(node -v)
# Remove 'v' prefix from versions for comparison
required_version=${required_node_version#v}
current_version=${current_node_version#v}
if [ "$required_version" != "$current_version" ]; then
echo "⚠️ Warning: Your Node.js version ($current_node_version) does not match the required version ($required_node_version)"
echo "Please consider switching to the correct version using: nvm use"
if [ -t 0 ]; then
read -p "Press Enter to continue with installation anyway..."
else
echo "Continuing with installation anyway..."
fi
echo
fi
fi
echo "Installing root-level dependencies..."
npm install