feat(pwsh): theme parameter is optional

This commit is contained in:
Jan De Dobbeleer 2020-09-20 08:53:14 +02:00 committed by Jan De Dobbeleer
parent 177f328ac6
commit 18746bdc4b

View file

@ -30,23 +30,17 @@ if ($IsWindows) {
function Set-PoshPrompt { function Set-PoshPrompt {
param( param(
[Parameter(Mandatory = $true)] [Parameter(Mandatory = $false)]
[string] [string]
$Theme $Theme
) )
$themePath = ""
if (Test-Path "$PSScriptRoot/Themes/$Theme.json") { if (Test-Path "$PSScriptRoot/Themes/$Theme.json") {
$themePath = "$PSScriptRoot/Themes/$Theme.json" $global:PoshSettings.Theme = "$PSScriptRoot/Themes/$Theme.json"
} }
elseif (Test-Path $Theme) { elseif (Test-Path $Theme) {
$themePath = $Theme $global:PoshSettings.Theme = $Theme
} }
else {
Write-Error -Message "Unable to locate theme, please verify the name and/or location"
return
}
$global:PoshSettings.Theme = $themePath
[ScriptBlock]$Prompt = { [ScriptBlock]$Prompt = {
$realLASTEXITCODE = $global:LASTEXITCODE $realLASTEXITCODE = $global:LASTEXITCODE