Make all config scripts platform independent
This commit is contained in:
parent
5f9815d1d9
commit
b0fb27f638
1 changed files with 13 additions and 5 deletions
|
@ -156,6 +156,14 @@ $null = New-Module {
|
|||
Invoke-ConfigScript "getConfig $Name --json $ArgumentList";
|
||||
}
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Gets the name of the config root.
|
||||
#>
|
||||
function Get-ConfigRootName {
|
||||
return "valhalla$($IsWindows ? ".windows" : '')";
|
||||
}
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Gets a user configuration.
|
||||
|
@ -168,13 +176,13 @@ $null = New-Module {
|
|||
#>
|
||||
function Get-UserConfig {
|
||||
param(
|
||||
[string] $UserName = $env:UserName,
|
||||
[string] $UserName = ($IsWindows ? $env:UserName : $env:USER),
|
||||
[Parameter(Mandatory, Position = 0)]
|
||||
[string] $Name
|
||||
)
|
||||
|
||||
if ((Get-Users) -contains $UserName) {
|
||||
Get-Config "valhalla.windows.users.$UserName.$Name";
|
||||
Get-Config "$(Get-ConfigRootName).users.$UserName.$Name";
|
||||
} else {
|
||||
return $null;
|
||||
}
|
||||
|
@ -202,7 +210,7 @@ $null = New-Module {
|
|||
function Get-Users {
|
||||
[OutputType([string[]])]
|
||||
param()
|
||||
Get-Attributes "valhalla.windows.users";
|
||||
Get-Attributes "$(Get-ConfigRootName).users";
|
||||
}
|
||||
|
||||
<#
|
||||
|
@ -212,7 +220,7 @@ $null = New-Module {
|
|||
function Get-SetupUser {
|
||||
[OutputType([string])]
|
||||
param()
|
||||
Get-Config "valhalla.windows.setupUser";
|
||||
Get-Config "$(Get-ConfigRootName).setupUser";
|
||||
}
|
||||
|
||||
<#
|
||||
|
@ -416,7 +424,7 @@ $null = New-Module {
|
|||
Checks whether the current user is the setup user.
|
||||
#>
|
||||
function Test-SetupUser {
|
||||
($IsWindows ? $env:UserName : $env:USER) -eq (Get-Config "valhalla.windows.setupUser");
|
||||
($IsWindows ? $env:UserName : $env:USER) -eq (Get-SetupUser);
|
||||
}
|
||||
|
||||
<#
|
||||
|
|
Loading…
Reference in a new issue