Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: check for nvm version in install script #4621

Merged
merged 2 commits into from
Mar 13, 2025
Merged

feat: check for nvm version in install script #4621

merged 2 commits into from
Mar 13, 2025

Conversation

Patrick-Erichsen
Copy link
Collaborator

No description provided.

Copy link

netlify bot commented Mar 12, 2025

Deploy Preview for continuedev canceled.

Name Link
🔨 Latest commit 18c5019
🔍 Latest deploy log https://app.netlify.com/sites/continuedev/deploys/67d2250a52fe4200088af25e

Copy link
Contributor

@owtaylor owtaylor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a good idea to me

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
Copy link
Contributor

@owtaylor owtaylor Mar 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could easily scroll off, maybe something like:

if [ -t 0 ] ; then
     read "Hit return to continue "
else
     echo "Continuing with installation anyway..."
fi

No idea how to do that in Powershell...

Copy link
Collaborator Author

@Patrick-Erichsen Patrick-Erichsen Mar 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure either but this was what 3.5 Sonnet generated 🤷

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
        }
    }
}

Our CI will at least catch if there are any issues with the install script in a non-interactive mode

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to add arch detection for nodejs?

@RomneyDa RomneyDa merged commit 2e5a8ce into main Mar 13, 2025
31 checks passed
@RomneyDa RomneyDa deleted the pe/nvm-warning branch March 13, 2025 00:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants