Add editorconfig, format script, and format all files consistently

This commit is contained in:
William Oldham 2024-12-30 13:28:11 +00:00
commit 944af73907
45 changed files with 552 additions and 517 deletions

5
.editorconfig Normal file
View file

@ -0,0 +1,5 @@
[*]
indent_style = tab
indent_size = 2
end_of_line = lf
insert_final_newline = false

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
error.log

View file

@ -1,13 +1,13 @@
{
"104": { "104": {
"0440": { "0440": {
"name": "Unknown", "name": "Unknown",
"message": "An error has occurred./n/nPlease try again later./n/nIf the problem persists, please\nmake a note of the error code and\nvisit support.nintendo.com.", "message": "An error has occurred./n/nPlease try again later./n/nIf the problem persists, please\nmake a note of the error code and\nvisit support.nintendo.com.",
"short_description": "Unknown cause.", "short_description": "Unknown cause.",
"long_description": "Unknown cause.", "long_description": "Unknown cause.",
"short_solution": "Unknown solution.", "short_solution": "Unknown solution.",
"long_solution": "Unknown solution.", "long_solution": "Unknown solution.",
"support_link": "https://preten.do/104-0440" "support_link": "https://preten.do/104-0440"
} }
} }
} }

29
format.sh Normal file
View file

@ -0,0 +1,29 @@
#!/bin/bash
# Remove any existing error log
rm -f error.log
# Enable recursive globbing
shopt -s globstar
# Process files in parallel using xargs
find data -type f -name "*.json" | xargs -n 1 -P "$(nproc)" -I {} bash -c '
file="{}"
echo "Processing file: $file"
jq --tab -j . <"$file" >"$file.out" 2>"$file.err"
if [ $? -eq 0 ]; then
mv "$file.out" "$file"
rm "$file.err"
else
echo "$file.err" >> error.log
rm "$file.out"
fi
'
# Print any files that failed to process
if [ -f error.log ] && [ "$(cat error.log | wc -l)" -gt 0 ]; then
echo "The following files failed to process:"
cat error.log | sed 's/^/ - /'
else
echo "All files processed successfully."
fi