Skip to content

Commit

Permalink
Tiny correction & replace some stuff in run.go
Browse files Browse the repository at this point in the history
  • Loading branch information
ntakouris authored and markbates committed Jan 8, 2018
1 parent 4c6faec commit 5499956
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 15 deletions.
16 changes: 3 additions & 13 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package cmd

import (
"fmt"
"os"
"os/exec"

"github.com/markbates/grift/grift"
"github.com/pkg/errors"
)

Expand Down Expand Up @@ -47,25 +47,15 @@ func Run(name string, args []string) error {
func run(args []string) error {
rargs := []string{"run", exePath}
rargs = append(rargs, args...)
runner := exec.Command("go", rargs...)
runner.Stdin = os.Stdin
runner.Stdout = os.Stdout
runner.Stderr = os.Stderr
err := runner.Run()
if err != nil {
if err := grift.RunSource(exec.Command("go", rargs...)); err != nil {
return errors.WithStack(err)
}

return nil
}

func list() error {
rargs := []string{"run", exePath, "list"}
runner := exec.Command("go", rargs...)
runner.Stderr = os.Stderr
runner.Stdin = os.Stdin
runner.Stdout = os.Stdout
return runner.Run()
return grift.RunSource(exec.Command("go", rargs...))
}

func setup(name string) error {
Expand Down
5 changes: 3 additions & 2 deletions grift/grift.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,12 @@ func PrintGrifts(w io.Writer) {
fmt.Fprintln(w, strings.Join([]string{m, suffix, descriptions[k]}, " "))
}
}

// RunSource executes the command passed as argument,
// in the current shell/context
func RunSource(cmd exec.Command) error{
func RunSource(cmd *exec.Cmd) error {
cmd.Stdin = os.Stdin
cmd.Stderr = os.Stderr
cmd.Stdout = os.Stdout
return cmd.Run()
}
}

0 comments on commit 5499956

Please sign in to comment.