mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-01-18 22:51:10 -08:00
parent
0a79f9764c
commit
0bdad6fa95
|
@ -15,7 +15,7 @@ func TestCmake(t *testing.T) {
|
||||||
}{
|
}{
|
||||||
{Case: "Cmake 3.23.2", ExpectedString: "3.23.2", Version: "cmake version 3.23.2"},
|
{Case: "Cmake 3.23.2", ExpectedString: "3.23.2", Version: "cmake version 3.23.2"},
|
||||||
{Case: "Cmake 2.3.13", ExpectedString: "2.3.12", Version: "cmake version 2.3.12"},
|
{Case: "Cmake 2.3.13", ExpectedString: "2.3.12", Version: "cmake version 2.3.12"},
|
||||||
{Case: "", ExpectedString: "", Version: ""},
|
{Case: "", ExpectedString: "err parsing info from cmake with", Version: ""},
|
||||||
}
|
}
|
||||||
for _, tc := range cases {
|
for _, tc := range cases {
|
||||||
params := &mockedLanguageParams{
|
params := &mockedLanguageParams{
|
||||||
|
|
|
@ -156,6 +156,7 @@ func (l *language) hasLanguageFolders() bool {
|
||||||
|
|
||||||
// setVersion parses the version string returned by the command
|
// setVersion parses the version string returned by the command
|
||||||
func (l *language) setVersion() error {
|
func (l *language) setVersion() error {
|
||||||
|
var lastError error
|
||||||
for _, command := range l.commands {
|
for _, command := range l.commands {
|
||||||
var versionStr string
|
var versionStr string
|
||||||
var err error
|
var err error
|
||||||
|
@ -166,20 +167,20 @@ func (l *language) setVersion() error {
|
||||||
versionStr, err = l.env.RunCommand(command.executable, command.args...)
|
versionStr, err = l.env.RunCommand(command.executable, command.args...)
|
||||||
if exitErr, ok := err.(*environment.CommandError); ok {
|
if exitErr, ok := err.(*environment.CommandError); ok {
|
||||||
l.exitCode = exitErr.ExitCode
|
l.exitCode = exitErr.ExitCode
|
||||||
return fmt.Errorf("err executing %s with %s", command.executable, command.args)
|
lastError = fmt.Errorf("err executing %s with %s", command.executable, command.args)
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
versionStr, err = command.getVersion()
|
versionStr, err = command.getVersion()
|
||||||
if err != nil {
|
if err != nil || versionStr == "" {
|
||||||
|
lastError = errors.New("cannot get version")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if versionStr == "" {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
version, err := command.parse(versionStr)
|
version, err := command.parse(versionStr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("err parsing info from %s with %s", command.executable, versionStr)
|
lastError = fmt.Errorf("err parsing info from %s with %s", command.executable, versionStr)
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
l.version = *version
|
l.version = *version
|
||||||
if command.versionURLTemplate != "" {
|
if command.versionURLTemplate != "" {
|
||||||
|
@ -189,6 +190,9 @@ func (l *language) setVersion() error {
|
||||||
l.version.Executable = command.executable
|
l.version.Executable = command.executable
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
if lastError != nil {
|
||||||
|
return lastError
|
||||||
|
}
|
||||||
return errors.New(l.props.GetString(MissingCommandText, ""))
|
return errors.New(l.props.GetString(MissingCommandText, ""))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,6 +66,15 @@ func TestPythonTemplate(t *testing.T) {
|
||||||
Template: "{{ if ne .Venv \"default\" }}{{ .Venv }} {{ end }}{{ .Major }}.{{ .Minor }}",
|
Template: "{{ if ne .Venv \"default\" }}{{ .Venv }} {{ end }}{{ .Major }}.{{ .Minor }}",
|
||||||
ResolveSymlink: ResolveSymlink{Path: "/home/user.pyenv/versions/3.8.8", Err: nil},
|
ResolveSymlink: ResolveSymlink{Path: "/home/user.pyenv/versions/3.8.8", Err: nil},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Case: "Pyenv virtual env version name",
|
||||||
|
FetchVersion: true,
|
||||||
|
VirtualEnvName: "demo",
|
||||||
|
Expected: "3.8.4",
|
||||||
|
PythonPath: "/home/user/.pyenv/shims/python",
|
||||||
|
Template: "{{ if .Error }}{{ .Error }}{{ else }}{{ .Full }}{{ end }}",
|
||||||
|
ResolveSymlink: ResolveSymlink{Path: "/home/user/.pyenv/versions/demo", Err: nil},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tc := range cases {
|
for _, tc := range cases {
|
||||||
|
|
Loading…
Reference in a new issue