mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-02-21 02:55:37 -08:00
parent
b0072ae039
commit
7dab387a11
|
@ -24,6 +24,9 @@ func (cfg *Config) Migrate(env environment.Environment) {
|
|||
for _, segment := range cfg.Tooltips {
|
||||
segment.migrate(env, cfg.Version)
|
||||
}
|
||||
if strings.Contains(cfg.ConsoleTitleTemplate, ".Path") {
|
||||
cfg.ConsoleTitleTemplate = strings.ReplaceAll(cfg.ConsoleTitleTemplate, ".Path", ".PWD")
|
||||
}
|
||||
cfg.updated = true
|
||||
cfg.Version = configVersion
|
||||
}
|
||||
|
|
|
@ -383,3 +383,22 @@ func TestMigratePreAndPostfix(t *testing.T) {
|
|||
assert.NotContains(t, segment.Properties, "postfix", tc.Case)
|
||||
}
|
||||
}
|
||||
|
||||
func TestMigrateConfig(t *testing.T) {
|
||||
cases := []struct {
|
||||
Case string
|
||||
Expected string
|
||||
Template string
|
||||
}{
|
||||
{Case: "Path", Expected: "{{ .PWD }}", Template: "{{ .Path }}"},
|
||||
{Case: "No Path", Expected: "foo", Template: "foo"},
|
||||
{Case: "Empty", Expected: "", Template: ""},
|
||||
}
|
||||
for _, tc := range cases {
|
||||
cfg := &Config{
|
||||
ConsoleTitleTemplate: tc.Template,
|
||||
}
|
||||
cfg.Migrate(&mock.MockedEnvironment{})
|
||||
assert.Equal(t, tc.Expected, cfg.ConsoleTitleTemplate, tc.Case)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue