Browse Source

Support for Run() convenience function

pull/1842/head
Jae Kwon 8 years ago
parent
commit
226eb6554f
1 changed files with 22 additions and 0 deletions
  1. +22
    -0
      util.go

+ 22
- 0
util.go View File

@ -0,0 +1,22 @@
package process
import (
. "github.com/tendermint/go-common"
)
// Runs a command and gets the result.
func Run(command string, args []string) (string, bool, error) {
outFile := NewBufferCloser(nil)
proc, err := StartProcess("", command, args, nil, outFile)
if err != nil {
return "", false, err
}
<-proc.WaitCh
if proc.ExitState.Success() {
return string(outFile.Bytes()), true, nil
} else {
return string(outFile.Bytes()), false, nil
}
}

Loading…
Cancel
Save