Make scripts platform independent

This commit is contained in:
Manuel Thalmann 2024-08-23 01:52:04 +02:00
parent 6b1aee97a6
commit 7fc0a0235c
2 changed files with 26 additions and 18 deletions

View file

@ -109,6 +109,8 @@ $null = New-Module {
$scriptPath = "$PSScriptRoot/../../Common/Scripts/config.fish";
if ($env:CONFIG_MODULE) {
$output = & {
if (-not $IsWindows) {
$escapedPath = (fish -c 'string escape $argv' "$scriptPath");
fish -c ". $escapedPath; $Script";
@ -122,12 +124,18 @@ $null = New-Module {
if (-not $?) {
Write-Error "The configuration could not be retrieved!";
} else {
$output;
}
}
}
if (-not ($output -and ($output | Test-Json))) {
Write-Error "The value ``$output`` is not valid JSON.";
} else {
$output | ConvertFrom-Json;
}
}
} else {
$null;
}
}
@ -408,7 +416,7 @@ $null = New-Module {
Checks whether the current user is the setup user.
#>
function Test-SetupUser {
$env:UserName -eq (Get-Config "valhalla.windows.setupUser");
($IsWindows ? $env:UserName : $env:USER) -eq (Get-Config "valhalla.windows.setupUser");
}
<#

View file

@ -255,7 +255,7 @@ $null = New-Module {
}
} elseif ($Action -eq ([InstallerAction]::ConfigureUser)) {
if ((-not $Arguments.ContainsKey($userArgument)) -or (-not $Arguments[$userArgument])) {
$Arguments.Add($userArgument, ($env:UserName));
$Arguments.Add($userArgument, ($IsWindows ? $env:UserName : $env:USER));
}
if ($UserConfigurator) {