Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Theme Filling Script #241

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions scripts/fillThemes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ fill_missing_values() {
local complete_theme_file="$1"
local target_theme_file="$2"

# Write the filename to the console
filename=$(basename "$target_theme_file")
echo "----------------------------------------"
echo "Processing $filename:"

# Load complete theme and target theme into variables
complete_theme=$(jq '.' "$complete_theme_file")
target_theme=$(jq '.' "$target_theme_file")
Expand Down Expand Up @@ -54,7 +59,7 @@ fill_missing_values() {
# Add missing property with the corresponding color
if [ -n "$corresponding_color" ]; then
filled_theme=$(echo "$filled_theme" | jq --arg key "$key" --arg value "$corresponding_color" '.[$key] = $value')
echo "Added missing property: $key with value: $corresponding_color to $target_theme_file"
echo "Added missing property: $key with value: $corresponding_color"
else
# Default action if no corresponding color is found
echo "No corresponding color found for $key; using value from complete theme."
Expand All @@ -63,9 +68,17 @@ fill_missing_values() {
fi
done

# Remove any extra properties only present in the target theme
for key in $(echo "$filled_theme" | jq -r 'keys_unsorted[]'); do
if ! echo "$complete_theme" | jq -e ".\"$key\"" &>/dev/null; then
filled_theme=$(echo "$filled_theme" | jq --arg key "$key" 'del(.[$key])')
echo "Removed extra property: $key"
fi
done

# Write the filled theme back to the target file
echo "$filled_theme" >"$target_theme_file"
echo "Filled missing values in $target_theme_file"
echo "Filled missing values in $filename"
}

# Process all theme files in the directory
Expand Down
Loading