From 7f507d69fa4c13b34e7a17ff5c87d1eaaa759145 Mon Sep 17 00:00:00 2001 From: Jae Kwon Date: Tue, 6 Dec 2016 02:08:05 -0800 Subject: [PATCH] Include pwd dir to StartProcess --- process.go | 3 ++- util.go | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/process.go b/process.go index cf2aa028..7d2ae914 100644 --- a/process.go +++ b/process.go @@ -24,8 +24,9 @@ type Process struct { // execPath: command name // args: args to command. (should not include name) -func StartProcess(label string, execPath string, args []string, inFile io.Reader, outFile io.WriteCloser) (*Process, error) { +func StartProcess(label string, dir string, execPath string, args []string, inFile io.Reader, outFile io.WriteCloser) (*Process, error) { cmd := exec.Command(execPath, args...) + cmd.Dir = dir cmd.Stdout = outFile cmd.Stderr = outFile cmd.Stdin = inFile diff --git a/util.go b/util.go index 4763ff71..4976e46e 100644 --- a/util.go +++ b/util.go @@ -5,9 +5,9 @@ import ( ) // Runs a command and gets the result. -func Run(command string, args []string) (string, bool, error) { +func Run(dir string, command string, args []string) (string, bool, error) { outFile := NewBufferCloser(nil) - proc, err := StartProcess("", command, args, nil, outFile) + proc, err := StartProcess("", dir, command, args, nil, outFile) if err != nil { return "", false, err }