Skip to content

Commit 9ee8a67

Browse files
authored
Merge pull request #248 from flant/hook-config-stderr
fix: log stderr for hook --config
2 parents ee77864 + 0c9ae50 commit 9ee8a67

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

pkg/hook/hook_manager.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package hook
33
import (
44
"fmt"
55
"os"
6+
"os/exec"
67
"path/filepath"
78
"sort"
89
"strings"
@@ -141,6 +142,9 @@ func (hm *hookManager) loadHook(hookPath string) (hook *Hook, err error) {
141142
configOutput, err := hm.execCommandOutput(hook.Name, hm.workingDir, hookPath, envs, []string{"--config"})
142143
if err != nil {
143144
hookEntry.Errorf("Hook config output:\n%s", string(configOutput))
145+
if ee, ok := err.(*exec.ExitError); ok && len(ee.Stderr) > 0 {
146+
hookEntry.Errorf("Hook config stderr:\n%s", string(ee.Stderr))
147+
}
144148
return nil, fmt.Errorf("cannot get config for hook '%s': %s", hookPath, err)
145149
}
146150

@@ -184,6 +188,7 @@ func (hm *hookManager) execCommandOutput(hookName string, dir string, entrypoint
184188
envs = append(os.Environ(), envs...)
185189
cmd := executor.MakeCommand(dir, entrypoint, args, envs)
186190
cmd.Stdout = nil
191+
cmd.Stderr = nil
187192

188193
debugEntry := log.WithField("hook", hookName).
189194
WithField("cmd", strings.Join(cmd.Args, " "))

0 commit comments

Comments
 (0)