Files

43 lines
1.2 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/zsh
echo "🎨 Depth-aware SCSS variables import patcher starting..."
VARIABLES_FILE="src/app/styles/variables.scss"
if [ ! -f "$VARIABLES_FILE" ]; then
echo "❌ variables.scss not found at: $VARIABLES_FILE"
exit 1
fi
# Normalize absolute path for comparison
VARIABLES_PATH=$(realpath "$VARIABLES_FILE")
# Find all SCSS files under src/app (excluding the variables file itself)
SCSS_FILES=$(find src/app -type f -name "*.scss" ! -path "*variables.scss")
for FILE in $SCSS_FILES; do
echo "🔍 Checking: $FILE"
# Skip if already importing variables
if grep -q 'variables' "$FILE"; then
echo " ✔ Already has variables import"
continue
fi
# Compute relative path from current SCSS file directory to variables.scss
FILE_DIR=$(dirname "$FILE")
REL_PATH=$(realpath --relative-to="$FILE_DIR" "$VARIABLES_PATH")
# Convert absolute to Sass import (remove leading ./ if present)
IMPORT_PATH="${REL_PATH#./}"
echo " Adding import: @import \"$IMPORT_PATH\";"
# Prepend import to file
echo "@import \"$IMPORT_PATH\";" | cat - "$FILE" > "$FILE.tmp"
mv "$FILE.tmp" "$FILE"
done
echo "🎉 Depth-aware SCSS import patching complete!"