Make Operations script cross platform

This commit is contained in:
Manuel Thalmann 2024-08-27 22:27:44 +02:00
parent 0083cecc6f
commit 376acef89f

View file

@ -195,18 +195,40 @@ $null = New-Module {
continue;
}
if (-not (Test-PSPackage Selenium.WebDriver)) {
Write-Host "Installing browser automation tools…";
$null = Install-Package -Force Selenium.WebDriver -RequiredVersion 4.10.0 -SkipDependencies;
continue;
}
Install-ChocoPackage selenium-gecko-driver firefox;
Install-WingetPackage AutoHotkey.AutoHotkey;
. "$PSScriptRoot/../../Windows/Software/PinnedItem/Manage.ps1";
}
Invoke-Hook "Install-PSModules" -Fallback {
$modules = @(
@("PSScriptAnalyzer")
) + (& {
if (-not $IsWindows) {
@()
} else {
@(
@("KnownFolders"),
@("PSWindowsUpdate"),
@("PSScriptAnalyzer"),
@("LocalAccounts", $true),
@("NuGet")
);
)
}
});
foreach ($module in $modules) {
$parameters = @{ };
if ($module -is [string]) {
$module = @($module);
}
if ($module[1]) {
$parameters = @{
allowPrerelease = $true;
@ -218,23 +240,12 @@ $null = New-Module {
Import-Module $module[0];
}
}
. "$PSScriptRoot/../../Windows/Software/PinnedItem/Manage.ps1";
};
if (-not (Test-PSPackage Selenium.WebDriver)) {
Write-Host "Installing browser automation tools…";
$null = Install-Package -Force Selenium.WebDriver -RequiredVersion 4.10.0 -SkipDependencies;
continue;
}
Install-ChocoPackage selenium-gecko-driver firefox;
Install-WingetPackage AutoHotkey.AutoHotkey;
$initialized = $true;
}
}
}
}
if ($taskPending) {
Start-OneShot;
@ -384,6 +395,8 @@ $null = New-Module {
Clears resources allocated during the operation.
#>
function Clear-OperationResources {
if ($IsWindows) {
Uninstall-WslDistribution;
}
}
};