兼容传入的工作目录为空的场景
This commit is contained in:
parent
eff08782cf
commit
2f8be1dea3
@ -44,7 +44,7 @@ func Execute(workDir string, command string, param []string) define.Result {
|
||||
var (
|
||||
fileInfo os.FileInfo
|
||||
)
|
||||
if fileInfo, result.Error = os.Stat(workDir); nil != result.Error {
|
||||
if fileInfo, result.Error = os.Stat(result.WorkDir); nil != result.Error {
|
||||
if !os.IsExist(result.Error) {
|
||||
return result
|
||||
}
|
||||
@ -53,14 +53,14 @@ func Execute(workDir string, command string, param []string) define.Result {
|
||||
}
|
||||
|
||||
if !fileInfo.IsDir() {
|
||||
result.Error = errors.New(workDir + " 工作目录不存在")
|
||||
result.Error = errors.New(result.WorkDir + " 工作目录不存在")
|
||||
}
|
||||
|
||||
if result.CmdPath, result.Error = Check(command); nil != result.Error {
|
||||
return result
|
||||
}
|
||||
cmdInstance := exec.Command(command, param...)
|
||||
cmdInstance.Dir = workDir
|
||||
cmdInstance.Dir = result.WorkDir
|
||||
result.Output, result.Error = cmdInstance.CombinedOutput()
|
||||
return result
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user