兼容传入的工作目录为空的场景
This commit is contained in:
parent
b8918397a5
commit
eff08782cf
@ -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
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user