improves script

This commit is contained in:
Nana Kofi Larbi Mantey
2024-10-28 17:06:10 +00:00
parent e3bda0de76
commit 6196c41a07
+16 -6
View File
@@ -12,11 +12,21 @@ if [ -z "${AWS_REGION}" ]; then
exit 1
fi
# Find and replace baked values with real values for the API_URI AND AWS_REGION
find /app/packages/dashboard/public /app/packages/dashboard/.next -type f -name "*.js" |
while read file; do
sed -i "s|PLUNK_API_URI|${API_URI}|g" "$file"
sed -i "s|PLUNK_AWS_REGION|${AWS_REGION}|g" "$file"
# Process each directory that might contain JS files
for dir in "/app/packages/dashboard/public" "/app/packages/dashboard/.next"; do
if [ -d "$dir" ]; then
# Find all JS files and process them
find "$dir" -type f -name "*.js" -o -name "*.mjs" | while read -r file; do
if [ -f "$file" ]; then
# Replace environment variables
sed -i "s|PLUNK_API_URI|${API_URI}|g" "$file"
sed -i "s|PLUNK_AWS_REGION|${AWS_REGION}|g" "$file"
echo "Processed: $file"
fi
done
else
echo "Warning: Directory $dir does not exist, skipping..."
fi
done
echo "Environment Variables Baked."
echo "Environment Variables Baked."