fix: fix the withHook func

Signed-off-by: monkey <golang@88.com>
This commit is contained in:
monkey 2023-01-21 00:02:44 +08:00
parent 4f38f2368d
commit 0ed4a4420f
1 changed files with 4 additions and 4 deletions

View File

@ -158,8 +158,8 @@ func (hs *hooks) setDefaultHook(d defaultHook) {
} }
func (hs *hooks) withProcessHook(ctx context.Context, cmd Cmder, hook ProcessHook) error { func (hs *hooks) withProcessHook(ctx context.Context, cmd Cmder, hook ProcessHook) error {
for _, h := range hs.slice { for i := len(hs.slice) - 1; i >= 0; i-- {
if wrapped := h.ProcessHook(hook); wrapped != nil { if wrapped := hs.slice[i].ProcessHook(hook); wrapped != nil {
hook = wrapped hook = wrapped
} }
} }
@ -169,8 +169,8 @@ func (hs *hooks) withProcessHook(ctx context.Context, cmd Cmder, hook ProcessHoo
func (hs *hooks) withProcessPipelineHook( func (hs *hooks) withProcessPipelineHook(
ctx context.Context, cmds []Cmder, hook ProcessPipelineHook, ctx context.Context, cmds []Cmder, hook ProcessPipelineHook,
) error { ) error {
for _, h := range hs.slice { for i := len(hs.slice) - 1; i >= 0; i-- {
if wrapped := h.ProcessPipelineHook(hook); wrapped != nil { if wrapped := hs.slice[i].ProcessPipelineHook(hook); wrapped != nil {
hook = wrapped hook = wrapped
} }
} }