mirror of
https://github.com/Infisical/infisical.git
synced 2026-01-09 15:38:03 -05:00
26 lines
652 B
Bash
Executable File
26 lines
652 B
Bash
Executable File
#!/bin/sh
|
|
|
|
ORIGINAL=$1
|
|
REPLACEMENT=$2
|
|
|
|
if [ "${ORIGINAL}" = "${REPLACEMENT}" ]; then
|
|
echo "Environment variable replacement is the same, skipping.."
|
|
exit 0
|
|
fi
|
|
|
|
echo "Replacing pre-baked value.."
|
|
|
|
# Escape special characters in REPLACEMENT for sed to avoid syntax errors
|
|
ESCAPED_REPLACEMENT=$(printf '%s\n' "$REPLACEMENT" | sed 's/[\/&]/\\&/g')
|
|
|
|
# Replace in JS files in assets directory
|
|
find assets -type f -name "*.js" |
|
|
while read file; do
|
|
sed -i "s|$ORIGINAL|$ESCAPED_REPLACEMENT|g" "$file"
|
|
done
|
|
|
|
# Replace in index.html (for asset references)
|
|
if [ -f "index.html" ]; then
|
|
sed -i "s|$ORIGINAL|$ESCAPED_REPLACEMENT|g" "index.html"
|
|
fi
|