Make Operations script cross platform

This commit is contained in:
Manuel Thalmann 2024-08-27 22:27:44 +02:00
parent d4360a4a15
commit 922f8d73e6

View file

@ -201,18 +201,40 @@ $null = New-Module {
continue; 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 { Invoke-Hook "Install-PSModules" -Fallback {
$modules = @( $modules = @(
@("PSScriptAnalyzer")
) + (& {
if (-not $IsWindows) {
@()
} else {
@(
@("KnownFolders"), @("KnownFolders"),
@("PSWindowsUpdate"), @("PSWindowsUpdate"),
@("PSScriptAnalyzer"),
@("LocalAccounts", $true), @("LocalAccounts", $true),
@("NuGet") @("NuGet")
); )
}
});
foreach ($module in $modules) { foreach ($module in $modules) {
$parameters = @{ }; $parameters = @{ };
if ($module -is [string]) {
$module = @($module);
}
if ($module[1]) { if ($module[1]) {
$parameters = @{ $parameters = @{
allowPrerelease = $true; allowPrerelease = $true;
@ -224,23 +246,12 @@ $null = New-Module {
Import-Module $module[0]; 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; $initialized = $true;
} }
} }
} }
}
if ($taskPending) { if ($taskPending) {
Start-OneShot; Start-OneShot;
@ -388,6 +399,8 @@ $null = New-Module {
Clears resources allocated during the operation. Clears resources allocated during the operation.
#> #>
function Clear-OperationResources { function Clear-OperationResources {
if ($IsWindows) {
Uninstall-WslDistribution; Uninstall-WslDistribution;
} }
}
}; };