Make scripts platform independent
This commit is contained in:
parent
6b1aee97a6
commit
7fc0a0235c
2 changed files with 26 additions and 18 deletions
|
@ -109,25 +109,33 @@ $null = New-Module {
|
|||
|
||||
$scriptPath = "$PSScriptRoot/../../Common/Scripts/config.fish";
|
||||
|
||||
if (-not $IsWindows) {
|
||||
$escapedPath = (fish -c 'string escape $argv' "$scriptPath");
|
||||
fish -c ". $escapedPath; $Script";
|
||||
} else {
|
||||
function fish {
|
||||
wsl --shell-type login -- nix --extra-experimental-features "nix-command flakes" run nixpkgs`#fish -- $args
|
||||
}
|
||||
|
||||
$output = fish -c ". $(ConvertTo-LinuxPath $scriptPath); $Script";
|
||||
|
||||
if (-not $?) {
|
||||
Write-Error "The configuration could not be retrieved!";
|
||||
} else {
|
||||
if (-not ($output -and ($output | Test-Json))) {
|
||||
Write-Error "The value ``$output`` is not valid JSON.";
|
||||
if ($env:CONFIG_MODULE) {
|
||||
$output = & {
|
||||
if (-not $IsWindows) {
|
||||
$escapedPath = (fish -c 'string escape $argv' "$scriptPath");
|
||||
fish -c ". $escapedPath; $Script";
|
||||
} else {
|
||||
$output | ConvertFrom-Json;
|
||||
function fish {
|
||||
wsl --shell-type login -- nix --extra-experimental-features "nix-command flakes" run nixpkgs`#fish -- $args
|
||||
}
|
||||
|
||||
$output = fish -c ". $(ConvertTo-LinuxPath $scriptPath); $Script";
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
<#
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue