Refactor the installation loop architecture

This commit is contained in:
Manuel Thalmann 2024-07-31 16:25:32 +02:00
parent 73c0648611
commit 467ad0caab
2 changed files with 36 additions and 25 deletions

View file

@ -29,8 +29,10 @@ function Start-InstallationLoop {
. "$PSScriptRoot/../Scripts/SetupConfig.ps1";
while (-not (Get-IsFinished)) {
switch (Get-Stage) {
$null {
if (-not (Get-Stage)) {
Set-Stage [SetupStage]::Initialize;
break;
} elseif (Get-Stage -eq [SetupStage]::Initialize) {
if (-not ((Get-Command "choco") -and (Get-Command "refreshenv"))) {
Invoke-Hook "Install-Chocolatey" -Fallback {
# Install chocolatey
@ -53,10 +55,14 @@ function Start-InstallationLoop {
if (Test-Path $env:PWSH_PATH) {
Remove-Item -Recurse $env:PWSH_PATH;
}
} else {
switch (Get-Stage) {
$null {
}
Default {}
}
}
}
}
function Invoke-WindowsInstallation([Context] $context) {

View file

@ -2,6 +2,11 @@ using namespace Microsoft.Win32;
using namespace System.Security.AccessControl;
using namespace System.Security.Principal;
enum SetupStage {
Initialize = "init"
Install = "install"
}
$null = New-Module {
[string] $configRoot = "HKLM:\Software\PortValhalla";
[string] $stageOption = "Stage";