From 078034b01e4eaf1f9436d46721f7cbe0d96eb8b4 Mon Sep 17 00:00:00 2001 From: technofab Date: Sun, 16 Nov 2025 20:56:57 +0100 Subject: [PATCH] fix(generator): fix leading newline in generated json files --- .gitignore | 1 + lib/lib.nix | 10 +++++----- nix/repo/soonix.nix | 9 +++++++++ 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 720f634..cbc7adf 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ result # soonix /test.yaml +/test.json # end soonix diff --git a/lib/lib.nix b/lib/lib.nix index a1abbff..cf82725 100644 --- a/lib/lib.nix +++ b/lib/lib.nix @@ -17,10 +17,10 @@ autogeneratedMessage = { - yaml = "# Generated by soonix, DO NOT EDIT"; - toml = "# Generated by soonix, DO NOT EDIT"; - lua = "--- Generated by soonix, DO NOT EDIT"; - xml = ""; + yaml = "# Generated by soonix, DO NOT EDIT\n"; + toml = "# Generated by soonix, DO NOT EDIT\n"; + lua = "--- Generated by soonix, DO NOT EDIT\n"; + xml = "\n"; }.${ format } or ""; @@ -31,7 +31,7 @@ '' ${pre.buildCommand} cp $out tmp - cat <(echo "${autogeneratedMessage}") tmp > $out + cat <(echo -n "${autogeneratedMessage}") tmp > $out ''; }); diff --git a/nix/repo/soonix.nix b/nix/repo/soonix.nix index 7983897..83882a7 100644 --- a/nix/repo/soonix.nix +++ b/nix/repo/soonix.nix @@ -22,5 +22,14 @@ in gitignore = true; }; }; + testJson = { + output = "test.json"; + data.hello = "world"; + opts.format = "json"; + hook = { + mode = "copy"; + gitignore = true; + }; + }; }; }).config