Skip to content

Commit

Permalink
fix detect empty display with no compatible
Browse files Browse the repository at this point in the history
Signed-off-by: Denis Vaumoron <dvaumoron@gmail.com>
  • Loading branch information
dvaumoron committed Jun 27, 2024
1 parent 2a42413 commit 228a647
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions cmd/tenv/subcmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ func newDetectCmd(conf *config.Config, versionManager versionmanager.VersionMana
detectedVersion, err := versionManager.Detect(false)
if err != nil {
loghelper.StdDisplay(err.Error())

if err != versionmanager.ErrNoCompatibleLocally {
return
}
}
loghelper.StdDisplay(loghelper.Concat(versionManager.FolderName, " ", detectedVersion, " will be run from this directory."))
},
Expand Down
6 changes: 3 additions & 3 deletions versionmanager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import (
var (
errEmptyVersion = errors.New("empty version")
errNoCompatible = errors.New("no compatible version found")
errNoCompatibleLocally = errors.New("no compatible version found locally")
ErrNoCompatibleLocally = errors.New("no compatible version found locally")
)

type ReleaseInfoRetriever interface {
Expand Down Expand Up @@ -314,7 +314,7 @@ func (m VersionManager) Uninstall(requestedVersion string) error {
func (m VersionManager) Use(requestedVersion string, workingDir bool) error {
detectedVersion, err := m.Evaluate(requestedVersion, false)
if err != nil {
if err != errNoCompatibleLocally {
if err != ErrNoCompatibleLocally {
return err
}

Expand All @@ -334,7 +334,7 @@ func (m VersionManager) autoInstallDisabledMsg(version string) error {
m.conf.Displayer.Flush(false) // Always normal display when installation is missing
m.conf.Displayer.Display(loghelper.Concat("Auto-install is disabled. To install ", m.FolderName, " version ", version, ", you can set environment variable TENV_AUTO_INSTALL=true, or install it via any of the following command: 'tenv ", cmdName, " install', 'tenv ", cmdName, " install ", version, "'"))

return errNoCompatibleLocally
return ErrNoCompatibleLocally
}

func (m VersionManager) checkVersionInstallation(version string) (bool, error) {
Expand Down

0 comments on commit 228a647

Please sign in to comment.