From f8d423f162268ed7734cb768ad40df9924b46bb2 Mon Sep 17 00:00:00 2001 From: mrfry Date: Tue, 11 Apr 2023 11:17:46 +0200 Subject: [PATCH] DOMAIN env var functionality improvements --- make.sh | 11 ++++++++--- src/constants.js | 4 +++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/make.sh b/make.sh index 01d86dc..99b5a78 100755 --- a/make.sh +++ b/make.sh @@ -2,11 +2,16 @@ scriptPath=$(dirname -- "${0}") domainPath="${scriptPath}/../../data/domain" -if [ ! -f "${domainPath}" ]; then - echo -e "\033[0;41m${domainPath} does not exist!\033[0m" +domain="${DOMAIN}" + +if [ -z "${domain}" ] && [ -f "${domainPath}" ]; then + domain=$(cat "${domainPath}") +fi + +if [ -z "${domain}" ]; then + echo -e "\033[0;41mDOMAIN is not set, and ${domainPath} does not exist!\033[0m" exit 1 fi -domain=$(cat "${domainPath}") NEXT_PUBLIC_DOMAIN="${domain}" npm run export diff --git a/src/constants.js b/src/constants.js index c963c8b..8bb2427 100644 --- a/src/constants.js +++ b/src/constants.js @@ -4,7 +4,9 @@ const useLocalhost = process && process.env.NODE_ENV === 'development' const domain = process && process.env.NEXT_PUBLIC_DOMAIN if (!domain && !useLocalhost) { - throw new Error('Domain is not defined! Please set DOMAIN env variable!') + throw new Error( + 'Domain is not defined! Please set NEXT_PUBLIC_DOMAIN env variable!' + ) } const constants = {