summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmis Shokoohi <amisshokoohi@gmail.com>2023-01-31 19:54:44 +0330
committerGitHub <noreply@github.com>2023-01-31 11:24:44 -0500
commit8c0b49bf039bc0b6ab72b44ef0e1e6587c76ad2b (patch)
tree9edfbfb4a2292fbfdf45c7091fc454489d45ed73
parent201b9b41f98aa28d7d0ad223bf3614b78312690d (diff)
cmd: `fmt` exit successfully after overwriting config file (#5351)
Fixes https://github.com/caddyserver/caddy/issues/5349
-rw-r--r--cmd/commandfuncs.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/cmd/commandfuncs.go b/cmd/commandfuncs.go
index bc4c227..c5264ed 100644
--- a/cmd/commandfuncs.go
+++ b/cmd/commandfuncs.go
@@ -558,7 +558,10 @@ func cmdFmt(fl Flags) (int, error) {
if err := os.WriteFile(formatCmdConfigFile, output, 0600); err != nil {
return caddy.ExitCodeFailedStartup, fmt.Errorf("overwriting formatted file: %v", err)
}
- } else if fl.Bool("diff") {
+ return caddy.ExitCodeSuccess, nil
+ }
+
+ if fl.Bool("diff") {
diff := difflib.Diff(
strings.Split(string(input), "\n"),
strings.Split(string(output), "\n"))