From b1a93b7a2dd22ab82ef9acdec5f1096c33c44c1b Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Wed, 12 Mar 2025 10:30:49 -0700 Subject: [PATCH 1/2] feat: check for `nvm` version in install script --- scripts/install-dependencies.ps1 | 17 +++++++++++++++++ scripts/install-dependencies.sh | 17 +++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/scripts/install-dependencies.ps1 b/scripts/install-dependencies.ps1 index c9ded6a0e..397d27bf1 100644 --- a/scripts/install-dependencies.ps1 +++ b/scripts/install-dependencies.ps1 @@ -25,6 +25,23 @@ 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 + Write-Host "Continuing with installation anyway...`n" -ForegroundColor Yellow + } +} + + # if ($null -eq $cargo) { # Write-Host "`n...`n" # Write-Host "Cargo`n" -ForegroundColor White diff --git a/scripts/install-dependencies.sh b/scripts/install-dependencies.sh index ac23cab05..8af49e13e 100755 --- a/scripts/install-dependencies.sh +++ b/scripts/install-dependencies.sh @@ -5,6 +5,23 @@ # - 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" + echo "Continuing with installation anyway..." + echo + fi +fi + echo "Installing root-level dependencies..." npm install From 18c50195248f6ca6c64e1eeb3cb8f10e6b85ffb5 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Wed, 12 Mar 2025 17:21:27 -0700 Subject: [PATCH 2/2] feat: allow input to exit --- scripts/install-dependencies.ps1 | 10 +++++++++- scripts/install-dependencies.sh | 7 ++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/scripts/install-dependencies.ps1 b/scripts/install-dependencies.ps1 index 397d27bf1..8a86bbca6 100644 --- a/scripts/install-dependencies.ps1 +++ b/scripts/install-dependencies.ps1 @@ -37,7 +37,15 @@ if (Test-Path ".nvmrc") { 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 - Write-Host "Continuing with installation anyway...`n" -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 + } } } diff --git a/scripts/install-dependencies.sh b/scripts/install-dependencies.sh index 8af49e13e..c3262e66c 100755 --- a/scripts/install-dependencies.sh +++ b/scripts/install-dependencies.sh @@ -17,7 +17,12 @@ if [ -f .nvmrc ]; then 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" - echo "Continuing with installation anyway..." + + if [ -t 0 ]; then + read -p "Press Enter to continue with installation anyway..." + else + echo "Continuing with installation anyway..." + fi echo fi fi