Skip to content

Commit 63524aa

Browse files
fix: environment variable injection modified
1 parent 734810b commit 63524aa

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

ichub-frontend/scripts/inject-dynamic-env.sh

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,18 @@ REQUIRE_HTTPS_URL_PATTERN \
3333
ICHUB_BACKEND_URL \
3434
"
3535

36-
# Execute envsubst with the defined variables
37-
envsubst "$(printf '${%s} ' $vars)" < "$source_file" > "$target_file"
36+
# base sed command: output source file and remove javascript comments
37+
sed_command="cat ${source_file} | sed -e \"s@^\\\s*//.*@@g\""
38+
39+
set -- $vars
40+
while [ -n "$1" ]; do
41+
var=$1
42+
# add a replace expression for each variable
43+
sed_command="${sed_command} -e \"s@${var}:\s*\\\".*\\\"@${var}: \\\"\${${var}}\\\"@g\""
44+
shift
45+
done
46+
47+
# execute the built replace command and write to target file
48+
echo ${sed_command} | sh > ${target_file}
3849

3950
echo "Variables injected correctly in $target_file"

0 commit comments

Comments
 (0)