Skip to content
This repository has been archived by the owner on Feb 24, 2024. It is now read-only.

show go.mod in buffalo info sort of fixes #1159 #1194

Merged
merged 5 commits into from
Aug 6, 2018
Merged
Changes from 4 commits
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
23 changes: 22 additions & 1 deletion buffalo/cmd/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"fmt"
"io"
"os"
"os/exec"
"reflect"
Expand Down Expand Up @@ -32,7 +33,10 @@ var infoCmd = &cobra.Command{
bb.WriteString(fmt.Sprintf("%s=%v\n", f.Name, rv.FieldByName(f.Name).Interface()))
}

return runInfoCmds()
if err := runInfoCmds(); err != nil {
return errors.WithStack(err)
}
return infoGoMod()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything looks good, but I have just a question, why we don't do something like:

return errors.WithStack(infoGoMod()), if the error is nil it will return nil anyway.

},
}

Expand All @@ -43,6 +47,23 @@ type infoCommand struct {
InfoLabel string
}

func infoGoMod() error {
if _, err := os.Stat("go.mod"); err != nil {
return nil
}
f, err := os.Open("go.mod")
if err != nil {
return errors.WithStack(err)
}
defer f.Close()

bb := os.Stdout
bb.WriteString("\n### go.mod\n")
io.Copy(bb, f)

return nil
}

func runInfoCmds() error {

commands := []infoCommand{
Expand Down