From a3ebb076a576dce4aa7964354ba24afa41e75313 Mon Sep 17 00:00:00 2001 From: "Krzysztof R." Date: Sat, 27 Apr 2024 19:02:56 +0200 Subject: [PATCH] feat: powershell now installs lts node version --- monorepo/run_windows.ps1 | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/monorepo/run_windows.ps1 b/monorepo/run_windows.ps1 index 8035d4c1..db358cba 100644 --- a/monorepo/run_windows.ps1 +++ b/monorepo/run_windows.ps1 @@ -18,6 +18,35 @@ function Get-LatestNodeLTSVersion { return $latestLTS } +# Set execution policy to allow scripts to run +Set-ExecutionPolicy Bypass -Scope Process -Force + +# Check if nvm is installed, if not download and install nvm-windows +$nvmDir = "$ENV:APPDATA\nvm" +if (-Not (Test-Path $nvmDir)) { + Write-Output "nvm-windows not found. Installing..." + # Download nvm-windows installer + $nvmInstaller = "https://github.com/coreybutler/nvm-windows/releases/download/1.1.10/nvm-setup.zip" + $outZip = "$ENV:TEMP\nvm-setup.zip" + Invoke-WebRequest -Uri $nvmInstaller -OutFile $outZip + + # Extract the installer + Expand-Archive -LiteralPath $outZip -DestinationPath $ENV:TEMP -Force + + # Run the installer + $installer = Get-ChildItem "$ENV:TEMP" -Filter "nvm-setup.exe" + Start-Process -FilePath $installer.FullName -Wait +} + +# Load nvm to use in the current session +& "$nvmDir\nvm.exe" + +# Install the latest LTS version of Node.js +nvm install lts + +# Use the latest LTS version +nvm use lts + # Install or upgrade Node.js if not the latest LTS $latestLTS = Get-LatestNodeLTSVersion if (-Not (Get-Command node -ErrorAction SilentlyContinue) -or -Not (Test-NodeInPath)) {