Skip to content

Commit

Permalink
fix: use empty stdin by default
Browse files Browse the repository at this point in the history
  • Loading branch information
mrexox committed Nov 30, 2023
1 parent 96e1fb5 commit 2e3d9ba
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion internal/lefthook/run/exec/execute_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,18 @@ type executeArgs struct {
interactive, useStdin bool
}

type nullReader struct{}

func (nullReader) Read(b []byte) (int, error) {
if len(b) == 0 {
return 0, nil
}

return 0, io.EOF
}

func (e CommandExecutor) Execute(ctx context.Context, opts Options, out io.Writer) error {
in := os.Stdin
var in io.Reader = nullReader{}
if opts.Interactive && !isatty.IsTerminal(os.Stdin.Fd()) {
tty, err := os.Open("/dev/tty")
if err == nil {
Expand Down

0 comments on commit 2e3d9ba

Please sign in to comment.