U cmd factory

This commit is contained in:
zhenorzz 2022-05-14 22:59:10 +08:00
parent 14a1482391
commit ada9adece6
6 changed files with 18 additions and 11 deletions

View File

@ -505,12 +505,8 @@ func (Deploy) Rebuild(gp *core.Goploy) core.Response {
afterDeployCommands = append(afterDeployCommands, cmdEntity.Symlink(destDir, project.Path))
afterDeployCommands = append(afterDeployCommands, cmdEntity.ChangeDirTime(destDir))
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))
afterDeployCommands = append(afterDeployCommands, scriptMode+" "+cmdEntity.Path(afterDeployScriptPath))
afterDeployCommands = append(afterDeployCommands, cmdEntity.Script(project.AfterDeployScriptMode, afterDeployScriptPath))
afterDeployCommands = append(afterDeployCommands, cmdEntity.Remove(afterDeployScriptPath))
}
// redirect to project path

View File

@ -292,12 +292,8 @@ func (gsync Gsync) remoteSync(msgChIn chan<- syncMessage) {
}
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))
afterDeployCommands = append(afterDeployCommands, scriptMode+" "+cmdEntity.Path(afterDeployScriptPath))
afterDeployCommands = append(afterDeployCommands, cmdEntity.Script(project.AfterDeployScriptMode, afterDeployScriptPath))
afterDeployCommands = append(afterDeployCommands, cmdEntity.Remove(afterDeployScriptPath))
}

View File

@ -9,6 +9,7 @@ type Cmd interface {
Remove(file string) string
Path(file string) string
ChangeDirTime(dir string) string
Script(mode, file string) string
}
func New(os string) Cmd {

View File

@ -12,6 +12,13 @@ import (
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 {
return fmt.Sprintf("touch -m %s", dir)
}

View File

@ -11,6 +11,13 @@ import (
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 {
tmpFile := w.Path(dir + "/goploy.tmp")
return fmt.Sprintf("type nul > %s && del %[1]s", tmpFile)

View File

@ -754,7 +754,7 @@ const scriptLangOption = [
{ label: 'bash', value: 'bash', lang: 'sh' },
{ label: 'python', value: 'python', lang: 'python' },
{ label: 'php', value: 'php', lang: 'php' },
{ label: 'bat', value: 'cmd /C', lang: 'batchfile' },
{ label: 'bat', value: 'cmd', lang: 'batchfile' },
]
const projectName = ref('')
const dialogVisible = ref(false)