zed-editor: survive if previous files are not JSON5 (#7351)

This commit is contained in:
Jairo Llopis 2025-07-03 13:44:20 +01:00 committed by GitHub
parent 426b405d97
commit b182e64c01
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 145 additions and 2 deletions

View file

@ -22,9 +22,9 @@ let
# No file? Create it
echo ${lib.escapeShellArg empty} > ${lib.escapeShellArg path}
fi
dynamic="$(${lib.getExe json5} --as-json ${lib.escapeShellArg path})"
dynamic="$(${lib.getExe json5} --as-json ${lib.escapeShellArg path} 2>/dev/null || echo ${lib.escapeShellArg empty})"
static="$(cat ${lib.escapeShellArg staticSettings})"
config="$(${lib.getExe pkgs.jq} -s ${lib.escapeShellArg jqOperation} --argjson dynamic "$dynamic" --argjson static "$static")"
config="$(${lib.getExe pkgs.jq} -n ${lib.escapeShellArg jqOperation} --argjson dynamic "$dynamic" --argjson static "$static")"
printf '%s\n' "$config" > ${lib.escapeShellArg path}
unset config
'';