Skip to content

Commit

Permalink
sort names in dump
Browse files Browse the repository at this point in the history
  • Loading branch information
kyoh86 committed Nov 13, 2020
1 parent 48900a0 commit 99969e4
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions internal/command/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"io"
"os"
"sort"

"github.com/kyoh86/gordon/internal/gordon"
)
Expand All @@ -20,11 +21,15 @@ func Dump(ev Env, bundleFile string) error {
writer = f
defer f.Close()
}
if err := gordon.WalkInstalledVersions(ev, func(ver gordon.Version) error {
fmt.Fprintln(writer, ver)
return nil
}); err != nil {
versions, err := gordon.ListInstalledVersions(ev)
if err != nil {
return err
}
sort.Slice(versions, func(i, j int) bool {
return versions[i].String() < versions[j].String()
})
for _, ver := range versions {
fmt.Fprintln(writer, ver)
}
return nil
}

0 comments on commit 99969e4

Please sign in to comment.