From 6eb34c350175c5f2e8400f67d31872e2441f822e Mon Sep 17 00:00:00 2001 From: Zack Spear Date: Wed, 2 Oct 2024 16:59:10 -0700 Subject: [PATCH] refactor(prebuild-webgui-set-env.sh): update default file paths and handle requested env file This commit updates the default file paths in the prebuild-webgui-set-env.sh script to use the requested env file instead of always using .env.production. If a specific env file is provided as an argument, its contents will be copied to .env. If the requested env file is not found, an error message will be displayed. --- web/scripts/prebuild-webgui-set-env.sh | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/web/scripts/prebuild-webgui-set-env.sh b/web/scripts/prebuild-webgui-set-env.sh index fd609ff74..ea04d8fdf 100755 --- a/web/scripts/prebuild-webgui-set-env.sh +++ b/web/scripts/prebuild-webgui-set-env.sh @@ -2,8 +2,8 @@ # Prevent incorrect vars from being used when building for the webgui -# Set the file paths -env_production=".env.production" +# Set the default file paths +env_requested="${1:-.env.production}" env_backup=".env.backup" env=".env" @@ -15,6 +15,11 @@ else echo "$env not found. Creating a new one." fi -# Copy contents from .env.production to .env -cp "$env_production" "$env" -echo "Contents of $env_production copied to $env" +# Copy contents from env_requested to .env +if [ -f "$env_requested" ]; then + cp "$env_requested" "$env" + echo "Contents of $env_requested copied to $env" +else + echo "Error: $env_requested not found." + exit 1 +fi