mirror of
https://gitee.com/goploy/goploy.git
synced 2024-12-03 12:39:44 +08:00
U cmd factory
This commit is contained in:
parent
14a1482391
commit
ada9adece6
@ -505,12 +505,8 @@ func (Deploy) Rebuild(gp *core.Goploy) core.Response {
|
|||||||
afterDeployCommands = append(afterDeployCommands, cmdEntity.Symlink(destDir, project.Path))
|
afterDeployCommands = append(afterDeployCommands, cmdEntity.Symlink(destDir, project.Path))
|
||||||
afterDeployCommands = append(afterDeployCommands, cmdEntity.ChangeDirTime(destDir))
|
afterDeployCommands = append(afterDeployCommands, cmdEntity.ChangeDirTime(destDir))
|
||||||
if len(project.AfterDeployScript) != 0 {
|
if len(project.AfterDeployScript) != 0 {
|
||||||
scriptMode := "bash"
|
|
||||||
if len(project.AfterDeployScriptMode) != 0 {
|
|
||||||
scriptMode = project.AfterDeployScriptMode
|
|
||||||
}
|
|
||||||
afterDeployScriptPath := path.Join(project.Path, "goploy-after-deploy."+utils.GetScriptExt(project.AfterDeployScriptMode))
|
afterDeployScriptPath := path.Join(project.Path, "goploy-after-deploy."+utils.GetScriptExt(project.AfterDeployScriptMode))
|
||||||
afterDeployCommands = append(afterDeployCommands, scriptMode+" "+cmdEntity.Path(afterDeployScriptPath))
|
afterDeployCommands = append(afterDeployCommands, cmdEntity.Script(project.AfterDeployScriptMode, afterDeployScriptPath))
|
||||||
afterDeployCommands = append(afterDeployCommands, cmdEntity.Remove(afterDeployScriptPath))
|
afterDeployCommands = append(afterDeployCommands, cmdEntity.Remove(afterDeployScriptPath))
|
||||||
}
|
}
|
||||||
// redirect to project path
|
// redirect to project path
|
||||||
|
@ -292,12 +292,8 @@ func (gsync Gsync) remoteSync(msgChIn chan<- syncMessage) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(project.AfterDeployScript) != 0 {
|
if len(project.AfterDeployScript) != 0 {
|
||||||
scriptMode := "bash"
|
|
||||||
if len(project.AfterDeployScriptMode) != 0 {
|
|
||||||
scriptMode = project.AfterDeployScriptMode
|
|
||||||
}
|
|
||||||
afterDeployScriptPath := path.Join(project.Path, "goploy-after-deploy."+utils.GetScriptExt(project.AfterDeployScriptMode))
|
afterDeployScriptPath := path.Join(project.Path, "goploy-after-deploy."+utils.GetScriptExt(project.AfterDeployScriptMode))
|
||||||
afterDeployCommands = append(afterDeployCommands, scriptMode+" "+cmdEntity.Path(afterDeployScriptPath))
|
afterDeployCommands = append(afterDeployCommands, cmdEntity.Script(project.AfterDeployScriptMode, afterDeployScriptPath))
|
||||||
afterDeployCommands = append(afterDeployCommands, cmdEntity.Remove(afterDeployScriptPath))
|
afterDeployCommands = append(afterDeployCommands, cmdEntity.Remove(afterDeployScriptPath))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ type Cmd interface {
|
|||||||
Remove(file string) string
|
Remove(file string) string
|
||||||
Path(file string) string
|
Path(file string) string
|
||||||
ChangeDirTime(dir string) string
|
ChangeDirTime(dir string) string
|
||||||
|
Script(mode, file string) string
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(os string) Cmd {
|
func New(os string) Cmd {
|
||||||
|
@ -12,6 +12,13 @@ import (
|
|||||||
|
|
||||||
type LinuxCmd struct{}
|
type LinuxCmd struct{}
|
||||||
|
|
||||||
|
func (c LinuxCmd) Script(mode, file string) string {
|
||||||
|
if mode == "" {
|
||||||
|
mode = "bash"
|
||||||
|
}
|
||||||
|
return fmt.Sprintf("%s %s", mode, file)
|
||||||
|
}
|
||||||
|
|
||||||
func (c LinuxCmd) ChangeDirTime(dir string) string {
|
func (c LinuxCmd) ChangeDirTime(dir string) string {
|
||||||
return fmt.Sprintf("touch -m %s", dir)
|
return fmt.Sprintf("touch -m %s", dir)
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,13 @@ import (
|
|||||||
|
|
||||||
type WindowsCmd struct{}
|
type WindowsCmd struct{}
|
||||||
|
|
||||||
|
func (w WindowsCmd) Script(mode, file string) string {
|
||||||
|
if mode == "" || mode == "cmd" {
|
||||||
|
mode = "cmd /C"
|
||||||
|
}
|
||||||
|
return fmt.Sprintf("%s %s", mode, w.Path(file))
|
||||||
|
}
|
||||||
|
|
||||||
func (w WindowsCmd) ChangeDirTime(dir string) string {
|
func (w WindowsCmd) ChangeDirTime(dir string) string {
|
||||||
tmpFile := w.Path(dir + "/goploy.tmp")
|
tmpFile := w.Path(dir + "/goploy.tmp")
|
||||||
return fmt.Sprintf("type nul > %s && del %[1]s", tmpFile)
|
return fmt.Sprintf("type nul > %s && del %[1]s", tmpFile)
|
||||||
|
@ -754,7 +754,7 @@ const scriptLangOption = [
|
|||||||
{ label: 'bash', value: 'bash', lang: 'sh' },
|
{ label: 'bash', value: 'bash', lang: 'sh' },
|
||||||
{ label: 'python', value: 'python', lang: 'python' },
|
{ label: 'python', value: 'python', lang: 'python' },
|
||||||
{ label: 'php', value: 'php', lang: 'php' },
|
{ label: 'php', value: 'php', lang: 'php' },
|
||||||
{ label: 'bat', value: 'cmd /C', lang: 'batchfile' },
|
{ label: 'bat', value: 'cmd', lang: 'batchfile' },
|
||||||
]
|
]
|
||||||
const projectName = ref('')
|
const projectName = ref('')
|
||||||
const dialogVisible = ref(false)
|
const dialogVisible = ref(false)
|
||||||
|
Loading…
Reference in New Issue
Block a user