Updates to update command

This commit is contained in:
Lea Anthony
2019-05-07 08:48:52 +10:00
parent bb3dbe0510
commit 0daec29fab
5 changed files with 31 additions and 6 deletions

View File

@@ -25,3 +25,16 @@ func (sh *ShellHelper) Run(command string, vars ...string) (stdout, stderr strin
stderr = string(stde.Bytes())
return
}
// RunInDirectory runs the given command in the given directory
func (sh *ShellHelper) RunInDirectory(dir string, command string, vars ...string) (stdout, stderr string, err error) {
cmd := exec.Command(command, vars...)
cmd.Dir = dir
var stdo, stde bytes.Buffer
cmd.Stdout = &stdo
cmd.Stderr = &stde
err = cmd.Run()
stdout = string(stdo.Bytes())
stderr = string(stde.Bytes())
return
}