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) --- 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 + } } }