summaryrefslogtreecommitdiffhomepage
path: root/cmd
diff options
context:
space:
mode:
authorY.Horie <[email protected]>2023-01-22 13:28:37 +0900
committerGitHub <[email protected]>2023-01-21 21:28:37 -0700
commit5805b3ca11492c2673180e707a643b24100a9e4a (patch)
tree090c20205e5576ebb3d32ab66531dd583d84eeba /cmd
parentd6d7511699f6a35e3246918023af5ba3bc2cbc67 (diff)
downloadcaddy-5805b3ca11492c2673180e707a643b24100a9e4a.tar.gz
caddy-5805b3ca11492c2673180e707a643b24100a9e4a.zip
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
Diffstat (limited to 'cmd')
-rw-r--r--cmd/commandfuncs.go4
1 files changed, 4 insertions, 0 deletions
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
}