Skip to content

Commit

Permalink
fix: use awk to change public dir in env of the home fe repo v2
Browse files Browse the repository at this point in the history
  • Loading branch information
tanhongit committed Nov 6, 2024
1 parent 581eead commit 20924e0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion setup/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ home_resource_env() {
# check and replace "PUBLIC_DIR=/Users/tanhongit/Data/CSlant/home-resource/public" to "PUBLIC_DIR=$HOME_RESOURCE_DIR/public"
if [ -f "$HOME_FE_DIR/.env" ] && ! grep -q "PUBLIC_DIR=$HOME_RESOURCE_DIR/public" "$HOME_FE_DIR/.env"; then
echo ' ∟ Setting up PUBLIC_DIR...'
awk -v var="PUBLIC_DIR=$HOME_RESOURCE_DIR/public" 'BEGIN{FS=OFS="="} $1=="PUBLIC_DIR"{$2=var}1' "$HOME_FE_DIR/.env" > temp && mv temp "$HOME_FE_DIR/.env"
awk -v HOME_RESOURCE_DIR="$HOME_RESOURCE_DIR" '/PUBLIC_DIR=/{gsub(/PUBLIC_DIR=.*/, "PUBLIC_DIR="HOME_RESOURCE_DIR"/public")}1' "$HOME_FE_DIR/.env" >"$HOME_FE_DIR/.env.tmp" && mv "$HOME_FE_DIR/.env.tmp" "$HOME_FE_DIR/.env"
else
echo ' ∟ PUBLIC_DIR already set up...'
fi
Expand Down

0 comments on commit 20924e0

Please sign in to comment.