From 5805b3ca11492c2673180e707a643b24100a9e4a Mon Sep 17 00:00:00 2001 From: "Y.Horie" Date: Sun, 22 Jan 2023 13:28:37 +0900 Subject: cmd: `caddy fmt` return code is 1 if not formatted (#5297) * cmd: Fix caddy fmt if input isn't formatted * Fixes #5294 * return exit 1 with an error message * cmd: Use formattingDifference for caddy fmt * #5294 * expose caddyfile.formattingDifference --- cmd/commandfuncs.go | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'cmd/commandfuncs.go') diff --git a/cmd/commandfuncs.go b/cmd/commandfuncs.go index e3daae59a..bc4c22781 100644 --- a/cmd/commandfuncs.go +++ b/cmd/commandfuncs.go @@ -576,6 +576,10 @@ func cmdFmt(fl Flags) (int, error) { fmt.Print(string(output)) } + if warning, diff := caddyfile.FormattingDifference(formatCmdConfigFile, input); diff { + return caddy.ExitCodeFailedStartup, fmt.Errorf("%s:%d: Caddyfile input is not formatted", warning.File, warning.Line) + } + return caddy.ExitCodeSuccess, nil } -- cgit v1.2.3