mirror of
https://github.com/1f349/site-hosting.git
synced 2025-01-20 22:26:37 +00:00
Don't fail upload if hook is missing
This commit is contained in:
parent
34ccdd8caa
commit
0506ff2d5f
11
hook/hook.go
11
hook/hook.go
@ -2,6 +2,7 @@ package hook
|
||||
|
||||
import (
|
||||
"github.com/cyphar/filepath-securejoin"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
)
|
||||
@ -28,6 +29,16 @@ func (h *Hook) Run(site, branch string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// check if the script exists before failing to execute
|
||||
_, err = os.Stat(scriptPath)
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
cmd := exec.Cmd{
|
||||
Path: scriptPath,
|
||||
Args: []string{filepath.Base(scriptPath)},
|
||||
|
Loading…
Reference in New Issue
Block a user