From 228a647813f07df9d76c635ff44b1ad156d90e51 Mon Sep 17 00:00:00 2001 From: Denis Vaumoron Date: Thu, 27 Jun 2024 18:04:53 +0200 Subject: [PATCH] fix detect empty display with no compatible Signed-off-by: Denis Vaumoron --- cmd/tenv/subcmd.go | 4 ++++ versionmanager/manager.go | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/cmd/tenv/subcmd.go b/cmd/tenv/subcmd.go index 0997a291..87b72bbf 100644 --- a/cmd/tenv/subcmd.go +++ b/cmd/tenv/subcmd.go @@ -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.")) }, diff --git a/versionmanager/manager.go b/versionmanager/manager.go index 32580bac..3859d605 100644 --- a/versionmanager/manager.go +++ b/versionmanager/manager.go @@ -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 { @@ -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 } @@ -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) {