From ce59538d3e860a7a999f888e2dc86ee1d5b04d21 Mon Sep 17 00:00:00 2001 From: yellowhatpro Date: Tue, 10 Sep 2024 09:43:48 +0530 Subject: [PATCH] fix: read env var RUN_MODE in scripts for CONFIG_FILE --- .gitignore | 3 ++- scripts/generate_fixtures.sh | 4 +++- scripts/init_db.sh | 4 +++- scripts/reinit_db.sh | 4 +++- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index c8f206e..3486aca 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ .idea .env config/production.toml -config/development.toml \ No newline at end of file +config/development.toml +config/default.toml \ No newline at end of file diff --git a/scripts/generate_fixtures.sh b/scripts/generate_fixtures.sh index 182553e..b9f95d9 100755 --- a/scripts/generate_fixtures.sh +++ b/scripts/generate_fixtures.sh @@ -6,7 +6,9 @@ if ! command -v yq &> /dev/null; then exit 1 fi -CONFIG_FILE="../config/development.toml" +export $(grep -v '^#' ../.env | xargs) + +CONFIG_FILE="../config/${RUN_MODE}.toml" PG_HOST=$(yq -p toml -r '.database.pg_host' "$CONFIG_FILE") PG_PORT=$(yq -p toml -r '.database.pg_port' "$CONFIG_FILE") diff --git a/scripts/init_db.sh b/scripts/init_db.sh index 2563294..e3db0b1 100755 --- a/scripts/init_db.sh +++ b/scripts/init_db.sh @@ -6,7 +6,9 @@ if ! command -v yq &> /dev/null; then exit 1 fi -CONFIG_FILE="../config/development.toml" +export $(grep -v '^#' ../.env | xargs) + +CONFIG_FILE="../config/${RUN_MODE}.toml" PG_HOST=$(yq -p toml -r '.database.pg_host' "$CONFIG_FILE") PG_PORT=$(yq -p toml -r '.database.pg_port' "$CONFIG_FILE") diff --git a/scripts/reinit_db.sh b/scripts/reinit_db.sh index 859c19b..d33a907 100755 --- a/scripts/reinit_db.sh +++ b/scripts/reinit_db.sh @@ -6,7 +6,9 @@ if ! command -v yq &> /dev/null; then exit 1 fi -CONFIG_FILE="../config/development.toml" +export $(grep -v '^#' ../.env | xargs) + +CONFIG_FILE="../config/${RUN_MODE}.toml" PG_HOST=$(yq -p toml -r '.database.pg_host' "$CONFIG_FILE") PG_PORT=$(yq -p toml -r '.database.pg_port' "$CONFIG_FILE")