兼容传入的工作目录为空的场景
This commit is contained in:
parent
b8918397a5
commit
eff08782cf
@ -22,6 +22,7 @@ import (
|
|||||||
//
|
//
|
||||||
// Date : 21:49 2022/5/20
|
// Date : 21:49 2022/5/20
|
||||||
func Execute(workDir string, command string, param []string) define.Result {
|
func Execute(workDir string, command string, param []string) define.Result {
|
||||||
|
|
||||||
//执行命令
|
//执行命令
|
||||||
result := define.Result{
|
result := define.Result{
|
||||||
WorkDir: workDir,
|
WorkDir: workDir,
|
||||||
@ -33,6 +34,13 @@ func Execute(workDir string, command string, param []string) define.Result {
|
|||||||
defer func() {
|
defer func() {
|
||||||
result.FinishTime = time.Now().UnixNano()
|
result.FinishTime = time.Now().UnixNano()
|
||||||
}()
|
}()
|
||||||
|
if len(workDir) == 0 {
|
||||||
|
// 默认为项目根目录
|
||||||
|
result.WorkDir, result.Error = os.Getwd()
|
||||||
|
}
|
||||||
|
if nil != result.Error {
|
||||||
|
return result
|
||||||
|
}
|
||||||
var (
|
var (
|
||||||
fileInfo os.FileInfo
|
fileInfo os.FileInfo
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user