fix(hooks): pre and post hooks now receive the full input line

Ayman Bagabas created

This fixes an issue where the pre and post hooks won't receive
the full input lines when they're split. This is because the
scanner is used to read the input line by line, and the scanner
strips the newline character from the input. This change adds
the newline character back to the input line before passing it
to the pre and post hooks.

Fixes: https://github.com/charmbracelet/soft-serve/issues/680

Change summary

cmd/soft/hook/hook.go | 1 +
1 file changed, 1 insertion(+)

Detailed changes

cmd/soft/hook/hook.go 🔗

@@ -80,6 +80,7 @@ var (
 			scanner := bufio.NewScanner(stdin)
 			for scanner.Scan() {
 				buf.Write(scanner.Bytes())
+				buf.WriteByte('\n')
 				fields := strings.Fields(scanner.Text())
 				if len(fields) != 3 {
 					return fmt.Errorf("invalid hook input: %s", scanner.Text())