Replace argfile by slurpfile (#8309)

This commit is contained in:
Max 2025-04-02 23:09:53 +02:00 committed by GitHub
parent 01845928b2
commit 4f02060fd7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 5 deletions

View File

@ -4,7 +4,7 @@
# by the corresponding values of target. If a key does not exist in target,
# the value is set to null.
#
# jq -n --argfile source en.json --argfile target es.json -f normalize-locales.jq
# jq -n --slurpfile source en.json --slurpfile target es.json -f normalize-locales.jq
#
# source should be primary or fallback locale file (here en.json)
# taget is the locale file to normalize (here es.json)
@ -22,10 +22,10 @@ def keys_to_paths_recursive($path):
then with_entries(
($path + [.key]) as $path |
if (.value | type == "string")
then .value |= ($target | find_key_by_path($path))
then .value |= ($target[0] | find_key_by_path($path))
else .value |= keys_to_paths_recursive($path)
end)
else .
end;
$source | keys_to_paths_recursive([])
$source[0] | keys_to_paths_recursive([])

View File

@ -9,8 +9,8 @@ for locale_file in "${locale_list[@]}"
do
jq -n \
-f $(dirname "$0")/normalize-locales.jq \
--argfile source $ROOT_DIR/webapp/locales/en.json \
--argfile target $ROOT_DIR/webapp/locales/$locale_file \
--slurpfile source $ROOT_DIR/webapp/locales/en.json \
--slurpfile target $ROOT_DIR/webapp/locales/$locale_file \
> "$tmp"
mv "$tmp" $ROOT_DIR/webapp/locales/$locale_file
done