Last active
November 26, 2022 19:22
-
-
Save quienn/9032648e74f3093e21f74610bd611ce7 to your computer and use it in GitHub Desktop.
Set-LuaVersion: hererocks Wrapper for Windows PowerShell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Set-LuaVersion { | |
param( | |
[string]$Hererocks = "$HOME\Dev\Lua", | |
[switch]$Jit, | |
[Parameter(Mandatory=$true,Position=0)] | |
[string]$Version | |
) | |
$LuaVersion = $(if ($Jit) { "jit$Version" } else { $Version }) | |
# If there's already a Lua version activated, run the deactivation script. | |
if (Get-Command deactivate-lua -ErrorAction SilentlyContinue) { | |
deactivate-lua | |
} | |
if (Test-Path "$Hererocks\$LuaVersion") { | |
. "$Hererocks\$LuaVersion\bin\activate.ps1" | |
} else { | |
Write-Warning "Downloading version $Version..." | |
# Starts the installation process of the missing $Version | |
if ($Jit) { | |
hererocks "$Hererocks\$LuaVersion" -j $Version -rlatest | |
} else { | |
hererocks "$Hererocks\$LuaVersion" -l $LuaVersion -rlatest | |
} | |
. "$Hererocks\$LuaVersion\bin\activate.ps1" | |
} | |
} | |
Set-Alias -Name slv -Value Set-LuaVersion |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment