Skip to content

Commit

Permalink
Fix upgrade (move configs we can't import)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaykul committed Sep 17, 2023
1 parent 3df1b4f commit 655e0c8
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
4 changes: 3 additions & 1 deletion Source/Classes/PowerLineTheme.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ Add-MetadataConverter @{
)
PSReadLineContinuationPrompt = '$($_.PSReadLineContinuationPrompt)'
PSReadLineContinuationPromptColor = '$($_.PSReadLineContinuationPromptColor)'
PSReadLineErrorColor = '$($_.PSReadLineErrorColor -join "','")'
$(if ($_.PSReadLineErrorColor) {
"PSReadLineErrorColor = '$($_.PSReadLineErrorColor -join "','")'"
})
HideErrors = $(if ($_.HideErrors) { '$true' } else { '$false' })
RepeatPrompt = '$(if ($_.RepeatPrompt) { $_.RepeatPrompt } else { 'CachedPrompt' })'
SetCurrentDirectory = $(if ($_.SetCurrentDirectory) { '$true' } else { '$false' })$(
Expand Down
8 changes: 4 additions & 4 deletions Source/PowerLine.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ FormatsToProcess = @("PowerLine.format.ps1xml")
NestedModules = @()

RequiredModules = @(
@{ModuleName="TerminalBlocks"; ModuleVersion="2.0.0"}
# Make sure we get the fixed version of Metadata
@{ModuleName="TerminalBlocks"; ModuleVersion="1.1.0"}
@{ModuleName="Metadata"; ModuleVersion="1.5.5"}
@{ModuleName="Configuration"; ModuleVersion="1.5.1"}
@{ModuleName="Pansies"; ModuleVersion="2.4.0"}
@{ModuleName="Metadata"; ModuleVersion="1.5.7"}
@{ModuleName="Configuration"; ModuleVersion="1.6.0"}
@{ModuleName="Pansies"; ModuleVersion="2.6.1"}
)
# RequiredAssemblies = "lib\PowerLine.dll"

Expand Down
24 changes: 23 additions & 1 deletion Source/Public/Set-PowerLinePrompt.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,30 @@ function Set-PowerLinePrompt {
}
}
process {
try {
[PowerLineTheme]$Local:PowerLineConfig = $Configuration | Update-Object $PSBoundParameters
} catch {
$ConfigPath = Join-Path (Get-ConfigurationPath) "Configuration.psd1"
$Date = Get-Date -f "yyyyMMdd"
$NewPath = [IO.Path]::ChangeExtension($ConfigPath, "$Date.psd1")
$Index = 0
while(Test-Path $NewPath) {
$Index++
$NewPath = [IO.Path]::ChangeExtension($ConfigPath, "$Date.$Index.psd1")
}
Write-Warning "Failed to import existing config, creating default prompt. Moved old '$ConfigPath' to '$NewPath'"
Move-Item $ConfigPath $NewPath -Force

[PowerLineTheme]$Local:PowerLineConfig = $Configuration | Update-Object $PSBoundParameters
try {
# Redo the import, so they get configuration from our default file
[PowerLineTheme]$Local:PowerLineConfig = Import-Configuration -ErrorAction SilentlyContinue | Update-Object @{
HideErrors = $HideErrors
SetCurrentDirectory = $SetCurrentDirectory
} | Update-Object $PSBoundParameters
} catch {
[PowerLineTheme]$Local:PowerLineConfig = $PSBoundParameters
}
}

# Set the default cap & separator before we cast prompt blocks
if ($NoBackground) {
Expand Down

0 comments on commit 655e0c8

Please sign in to comment.