formats.javaProperties: Add comment

This commit is contained in:
Robert Hensing 2022-03-28 09:23:25 +02:00
parent 4f8e44394c
commit 9a0739cbe2
2 changed files with 11 additions and 4 deletions

View file

@ -1,6 +1,6 @@
{ lib, pkgs }: { lib, pkgs }:
{ {
javaProperties = {}: { javaProperties = { comment ? "Generated with Nix" }: {
type = lib.types.attrsOf lib.types.str; type = lib.types.attrsOf lib.types.str;
generate = name: value: generate = name: value:
@ -76,10 +76,15 @@
inputEncoding = "UTF-8"; inputEncoding = "UTF-8";
inherit comment;
} '' } ''
jq -r --arg hash '#' "$jqCode" "$valuePath" \ (
| iconv --from-code "$inputEncoding" --to-code JAVA \ echo "$comment" | while read -r ln; do echo "# $ln"; done
> "$out" echo
jq -r --arg hash '#' "$jqCode" "$valuePath" \
| iconv --from-code "$inputEncoding" --to-code JAVA \
) > "$out"
''; '';
}; };
} }

View file

@ -179,6 +179,8 @@ in runBuildTests {
"الجبر" = "أكثر من مجرد أرقام"; "الجبر" = "أكثر من مجرد أرقام";
}; };
expected = '' expected = ''
# Generated with Nix
1 = 2 1 = 2
foo = bar foo = bar
\u00fctf\ 8 = d\u00fbh \u00fctf\ 8 = d\u00fbh