mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-12-27 11:59:40 -08:00
fix(migrate): correctly migrate exit segment
This commit is contained in:
parent
dec5691435
commit
39dfca93c6
|
@ -134,16 +134,16 @@ func (segment *Segment) migrationOne(env environment.Environment) {
|
|||
template = strings.ReplaceAll(template, ".Text", ".Meaning")
|
||||
segment.Properties[properties.SegmentTemplate] = template
|
||||
}
|
||||
displayExitCode := properties.Property("display_exit_code")
|
||||
if !segment.Properties.GetBool(displayExitCode, true) {
|
||||
delete(segment.Properties, displayExitCode)
|
||||
template = strings.ReplaceAll(template, " {{ .Meaning }}", "")
|
||||
}
|
||||
alwaysNumeric := properties.Property("always_numeric")
|
||||
if segment.Properties.GetBool(alwaysNumeric, false) {
|
||||
delete(segment.Properties, alwaysNumeric)
|
||||
template = strings.ReplaceAll(template, ".Meaning", ".Code")
|
||||
}
|
||||
displayExitCode := properties.Property("display_exit_code")
|
||||
if !segment.Properties.GetBool(displayExitCode, true) {
|
||||
delete(segment.Properties, displayExitCode)
|
||||
template = " "
|
||||
}
|
||||
segment.Properties[properties.SegmentTemplate] = template
|
||||
segment.migrateTemplate()
|
||||
segment.migrateIconOverride("success_icon", "\uf42e")
|
||||
|
|
|
@ -221,7 +221,7 @@ func TestSegmentTemplateMigration(t *testing.T) {
|
|||
},
|
||||
{
|
||||
Case: "EXIT - No exit code",
|
||||
Expected: " ",
|
||||
Expected: " {{ if gt .Code 0 }}FAIL{{ else }}SUCCESS{{ end }} ",
|
||||
Type: EXIT,
|
||||
Props: properties.Map{
|
||||
"display_exit_code": false,
|
||||
|
@ -229,6 +229,19 @@ func TestSegmentTemplateMigration(t *testing.T) {
|
|||
"error_icon": "FAIL",
|
||||
},
|
||||
},
|
||||
{
|
||||
Case: "EXIT - No spaces",
|
||||
Expected: "{{ if gt .Code 0 }}💩{{ else }}🌵{{ end }}",
|
||||
Type: EXIT,
|
||||
Props: properties.Map{
|
||||
"prefix": "",
|
||||
"postfix": "",
|
||||
"display_exit_code": false,
|
||||
"always_enabled": true,
|
||||
"success_icon": "🌵",
|
||||
"error_icon": "💩",
|
||||
},
|
||||
},
|
||||
{
|
||||
Case: "EXIT - Always numeric",
|
||||
Expected: " {{ if gt .Code 0 }}FAIL {{ .Code }}{{ else }}SUCCESS{{ end }} ",
|
||||
|
|
Loading…
Reference in a new issue