Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix flow version output bug #1490

Merged
merged 2 commits into from
Apr 2, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions internal/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ package version
import (
"encoding/json"
"fmt"
"log"
"runtime/debug"
"strings"

Expand All @@ -45,12 +44,12 @@ func (c versionCmd) Print(format string) error {
txtBuilder.WriteString(fmt.Sprintf("Version: %s\n", c.Version))
txtBuilder.WriteString(fmt.Sprintf("Commit: %s\n", c.Commit))

txtBuilder.WriteString(fmt.Sprintf("\nFlow Package Dependencies \n"))
txtBuilder.WriteString("\nFlow Package Dependencies \n")
for _, dep := range c.Dependencies {
txtBuilder.WriteString(fmt.Sprintf("%s %s\n", dep.Path, dep.Version))
}

log.Println(txtBuilder.String())
fmt.Println(txtBuilder.String())

return nil

Expand All @@ -60,7 +59,7 @@ func (c versionCmd) Print(format string) error {
return err
}

log.Println(string(jsonRes))
fmt.Println(string(jsonRes))

return nil

Expand Down Expand Up @@ -99,7 +98,7 @@ func (c *versionCmd) MarshalJSON() ([]byte, error) {
var Cmd = &cobra.Command{
Use: "version",
Short: "View version and commit information",
Run: func(cmd *cobra.Command, args []string) {
RunE: func(cmd *cobra.Command, args []string) error {
semver := build.Semver()
commit := build.Commit()

Expand All @@ -110,8 +109,7 @@ var Cmd = &cobra.Command{

bi, ok := debug.ReadBuildInfo()
if !ok {
log.Printf("Failed to read build info")
return
return fmt.Errorf("failed to read build info")
}

// only add dependencies from github.com/onflow
Expand All @@ -122,8 +120,9 @@ var Cmd = &cobra.Command{
}

if err := v.Print(command.Flags.Format); err != nil {
log.Printf("Failed to print version information: %s", err)
return
return err
}

return nil
},
}
Loading