Skip to content

Commit 6deb5fa

Browse files
committed
.env variables update
1 parent 11de111 commit 6deb5fa

File tree

2 files changed

+39
-4
lines changed

2 files changed

+39
-4
lines changed

.cdmrc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
tabs: ['src/App.jsx']
1+
tabs: ["src/App.jsx"]
22
live-reload-browser: false
3-
terminal-one: |
4-
yarn install
5-
yarn dev
3+
terminals: ["yarn install && yarn dev", "bash env-script.sh"]

env-script.sh

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/bash
2+
3+
# Do NOT Delete This script file, this is used for setting up
4+
# the basic ENV variables that you may need to use
5+
6+
# Fetch environment variables containing "PUBLIC"
7+
env_variables=$(printenv | grep "PUBLIC")
8+
9+
# Create a temporary file for storing the new environment variables
10+
temp_file=$(mktemp)
11+
12+
# Iterate over each environment variable
13+
while IFS= read -r line; do
14+
# Extract the variable name
15+
variable_name=$(echo "$line" | cut -d '=' -f 1)
16+
17+
# Join with "VITE_" prefix
18+
new_variable_name="VITE_${variable_name}"
19+
20+
# Append to temporary file
21+
echo -e "\n$new_variable_name=${!variable_name}" >> "$temp_file"
22+
done <<< "$env_variables"
23+
24+
# Cleanup: Delete existing environment variables in .env file with the same keys
25+
while IFS= read -r line; do
26+
# Extract the variable name from the .env file
27+
existing_variable_name=$(echo "$line" | cut -d '=' -f 1)
28+
29+
# Remove the corresponding line from the .env file
30+
sed -i "/^$existing_variable_name=/d" .env
31+
done < "$temp_file"
32+
33+
# Append the new environment variables to the .env file
34+
cat "$temp_file" >> .env
35+
36+
# Remove the temporary file
37+
rm "$temp_file"

0 commit comments

Comments
 (0)