From 9fa5f0d7c8d64b2cb6113f310e8a8c678968da05 Mon Sep 17 00:00:00 2001 From: oliverpool Date: Wed, 4 Feb 2026 08:09:41 +0100 Subject: [PATCH 1/2] fmt: always output content when formatting stdin Fixes #1577 --- d2cli/fmt.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/d2cli/fmt.go b/d2cli/fmt.go index 61daf15ea0..550eef1711 100644 --- a/d2cli/fmt.go +++ b/d2cli/fmt.go @@ -54,6 +54,12 @@ func fmtCmd(ctx context.Context, ms *xmain.State, check bool) (err error) { return err } } + } else if !check && inputPath == "-" { + // still output unchanged file to prevent deletion in + // automated setups + if err := ms.WritePath(inputPath, output); err != nil { + return err + } } } From 1d134d4c3175d561cdd19f3f77d69fec24f46243 Mon Sep 17 00:00:00 2001 From: oliverpool Date: Wed, 4 Feb 2026 08:11:55 +0100 Subject: [PATCH 2/2] add changelog --- ci/release/changelogs/next.md | 1 + 1 file changed, 1 insertion(+) diff --git a/ci/release/changelogs/next.md b/ci/release/changelogs/next.md index f4616390ed..b9820e928d 100644 --- a/ci/release/changelogs/next.md +++ b/ci/release/changelogs/next.md @@ -19,6 +19,7 @@ - exports: pptx follows standards more closely, addressing warnings from some Powerpoint software [#2645](https://github.com/terrastruct/d2/pull/2645) - d2sequence: fix edge case of invalid sequence diagrams [#2660](https://github.com/terrastruct/d2/pull/2660) - d2svg: Text may overflow legend bounds when monospace font is used [#2674](https://github.com/terrastruct/d2/pull/2674) +- fmt: always output content when formatting stdin [#2718](https://github.com/terrastruct/d2/pull/2718) ---