Skip to content

Commit 89c0764

Browse files
committed
refactor: use new helper
1 parent 7e906f1 commit 89c0764

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

cmd/ls.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"errors"
55
"fmt"
66
"os"
7-
"path/filepath"
87
"sort"
98

109
"github.com/dpastoor/qvm/internal/config"
@@ -36,10 +35,6 @@ func newLs(lsOpts lsOpts) error {
3635
fmt.Printf("%s | %s | %s\n", r.GetTagName(), createdAt.Format("2006-01-02"), r.GetName())
3736
}
3837
} else {
39-
activePath, err := filepath.EvalSymlinks(filepath.Join(config.GetPathToActiveBinDir(), "quarto"))
40-
if err != nil && !errors.Is(err, os.ErrNotExist) {
41-
return err
42-
}
4338
entries, err := os.ReadDir(config.GetPathToVersionsDir())
4439
if errors.Is(err, os.ErrNotExist) {
4540
fmt.Println("No installed quarto versions found")
@@ -61,11 +56,14 @@ func newLs(lsOpts lsOpts) error {
6156
sort.Slice(entries, func(i, j int) bool {
6257
return entries[i].Name() > entries[j].Name()
6358
})
59+
// no need to worry about errors since just need to know version
60+
// for matching below and won't match if doesn't exist
61+
activeVersion, _ := config.GetActiveVersion()
6462
for _, e := range entries {
6563
if e.IsDir() {
6664
dinfo, _ := e.Info()
6765
name := e.Name()
68-
if filepath.Base(filepath.Dir(filepath.Dir(activePath))) == e.Name() {
66+
if activeVersion == e.Name() {
6967
name += " (active)"
7068
} else {
7169
name += " "

0 commit comments

Comments
 (0)