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

Commit

Permalink
Merge pull request #756 from gobuffalo/improved-info
Browse files Browse the repository at this point in the history
print out the yarn version and dep version
  • Loading branch information
markbates authored Nov 14, 2017
2 parents a4cf642 + 938fa7c commit d897a2d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
31 changes: 31 additions & 0 deletions buffalo/cmd/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import (
"fmt"
"os"
"os/exec"
"reflect"

"github.com/gobuffalo/buffalo/meta"
"github.com/gobuffalo/envy"
"github.com/pkg/errors"
"github.com/spf13/cobra"
Expand All @@ -19,6 +21,15 @@ var infoCmd = &cobra.Command{

bb.WriteString(fmt.Sprintf("### Buffalo Version\n%s\n", Version))

bb.WriteString("\n### App Information\n")
app := meta.New(".")
rv := reflect.ValueOf(app)
rt := rv.Type()
for i := 0; i < rt.NumField(); i++ {
f := rt.Field(i)
bb.WriteString(fmt.Sprintf("%s=%v\n", f.Name, rv.FieldByName(f.Name).Interface()))
}

bb.WriteString("\n### Go Version\n")
c := exec.Command(envy.Get("GO_BIN", "go"), "version")
c.Stdout = bb
Expand Down Expand Up @@ -53,6 +64,26 @@ var infoCmd = &cobra.Command{
bb.WriteString("NPM Not Found\n")
}

bb.WriteString("\n### Yarn Version\n")
if _, err := exec.LookPath("yarn"); err == nil {
c = exec.Command("yarn", "--version")
c.Stdout = bb
c.Stderr = bb
c.Run()
} else {
bb.WriteString("Yarn Not Found\n")
}

bb.WriteString("\n### Dep Version\n")
if _, err := exec.LookPath("dep"); err == nil {
c = exec.Command("dep", "version")
c.Stdout = bb
c.Stderr = bb
c.Run()
} else {
bb.WriteString("dep Not Found\n")
}

bb.WriteString("\n### Dep Status\n")
if _, err := exec.LookPath("dep"); err == nil {
c = exec.Command("dep", "status")
Expand Down
2 changes: 1 addition & 1 deletion meta/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ type App struct {
// New App based on the details found at the provided root path
func New(root string) App {
pwd, _ := os.Getwd()
pp := packagePath(root)
if root == "." {
root = pwd
}
pp := packagePath(root)

app := App{
Pwd: pwd,
Expand Down

0 comments on commit d897a2d

Please sign in to comment.