兼容传入的工作目录为空的场景

This commit is contained in:
白茶清欢 2022-05-21 19:06:06 +08:00
parent b8918397a5
commit eff08782cf

View File

@ -22,6 +22,7 @@ import (
//
// Date : 21:49 2022/5/20
func Execute(workDir string, command string, param []string) define.Result {
//执行命令
result := define.Result{
WorkDir: workDir,
@ -33,6 +34,13 @@ func Execute(workDir string, command string, param []string) define.Result {
defer func() {
result.FinishTime = time.Now().UnixNano()
}()
if len(workDir) == 0 {
// 默认为项目根目录
result.WorkDir, result.Error = os.Getwd()
}
if nil != result.Error {
return result
}
var (
fileInfo os.FileInfo
)