From c682219542e55fc849be5cde3141b892ebf6498f Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Tue, 6 Aug 2024 16:54:11 +0200 Subject: [PATCH] Add a separate function for executing software actions --- scripts/Windows/OS/Install.ps1 | 38 ++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/scripts/Windows/OS/Install.ps1 b/scripts/Windows/OS/Install.ps1 index 809ed8d07..24eb2a7af 100644 --- a/scripts/Windows/OS/Install.ps1 +++ b/scripts/Windows/OS/Install.ps1 @@ -13,6 +13,7 @@ $null = New-Module { . "$PSScriptRoot/../Scripts/PowerManagement.ps1"; . "$PSScriptRoot/../Scripts/SoftwareManagement.ps1"; . "$PSScriptRoot/../Scripts/Update.ps1"; + . "$PSScriptRoot/../Types/InstallerAction.ps1"; <# .SYNOPSIS @@ -94,6 +95,33 @@ $null = New-Module { return; } + <# + .SYNOPSIS + Deploys an action for each software. + + .PARAMETER Action + The action to execute by default. + #> + function Deploy-SoftwareAction { + param( + [InstallerAction] $Action + ) + + $arguments = [hashtable]@{ }; + + if ($Action) { + $arguments.Add("action", $Action); + } + + # Windows Config + . "$PSScriptRoot/../Software/Windows/Manage.ps1" @arguments; + + if (Test-Collection "essential") { + # Essentials + . "$PSScriptRoot/../Software/OpenSSH/Manage.ps1" @arguments; + } + } + switch (Get-Stage) { ([SetupStage]::Configure) { if (Get-Config "valhalla.windows.dualboot.enable") { @@ -115,15 +143,7 @@ $null = New-Module { } ([SetupStage]::Install) { Write-Host "Entering install phase"; - - # Windows Config - . "$PSScriptRoot/../Software/Windows/Manage.ps1"; - - if (Test-Collection "essential") { - # Essentials - . "$PSScriptRoot/../Software/OpenSSH/Manage.ps1"; - } - + Deploy-SoftwareAction; Set-IsFinished $true; } }