Files
SuperSunday/apply_header_patch.sh
2025-08-24 23:47:39 +00:00

21 lines
558 B
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.
#!/usr/bin/env bash
set -euo pipefail
ROOT="${1:-.}"
BASE="$ROOT/frontend/public"
[ -d "$BASE" ] || { echo "❌ Dossier $BASE introuvable"; exit 1; }
script_tag='<script type="module" src="/assets/header.js?v=1"></script>'
# Inject before </body> in all .html if not already present
while IFS= read -r -d '' page; do
if ! grep -q 'assets/header.js' "$page"; then
sed -i '' -e "s#</body># ${script_tag}
</body>#g" "$page"
echo " header.js -> $page"
fi
done < <(find "$BASE" -type f -name "*.html" -print0)
echo "✅ Injection terminée."