fix to use with sveltekit
This commit is contained in:
54
bin/helper/fn
Executable file
54
bin/helper/fn
Executable file
@@ -0,0 +1,54 @@
|
||||
#!/bin/sh
|
||||
|
||||
abort() {
|
||||
printf "\n \033[31mError: $@\033[0m\n\n" && exit 1
|
||||
}
|
||||
|
||||
ok() {
|
||||
printf "\n \033[32mOk: $@\033[0m\n\n"
|
||||
}
|
||||
|
||||
load_env() {
|
||||
_DIR="$(pwd)"
|
||||
ENVFILE_LOCAL="${2:-$_DIR}/.conf/local.sh"
|
||||
ENVFILE_OPT="${2:-$_DIR}/.conf/${1:-development}.sh"
|
||||
USE_LOCAL_ENV=0
|
||||
|
||||
if test ! -e $ENVFILE_OPT; then
|
||||
abort "Environment file not found"
|
||||
fi
|
||||
|
||||
set -a
|
||||
. ${ENVFILE_OPT}
|
||||
set +a
|
||||
|
||||
if test "${1}" = "development" -o "${1}" = "test"; then
|
||||
USE_LOCAL_ENV=1
|
||||
fi
|
||||
|
||||
if test -e $ENVFILE_LOCAL -a "${USE_LOCAL_ENV:-0}" = "1"; then
|
||||
set -a
|
||||
. ${ENVFILE_LOCAL}
|
||||
set +a
|
||||
fi
|
||||
}
|
||||
|
||||
gen_env() {
|
||||
_DIR="$(cd $(dirname $0) && pwd)"
|
||||
_BIN_DIR="$(cd $DIR/.. && pwd)"
|
||||
GEN_ENV="${2:-$_BIN_DIR}/node/env.js"
|
||||
|
||||
if test -z $1; then
|
||||
abort "Missing output"
|
||||
fi
|
||||
|
||||
if test ! -f "${GEN_ENV}"; then
|
||||
abort "File not found: ${GEN_ENV}"
|
||||
fi
|
||||
|
||||
_DIR_FILE=$(dirname $1)
|
||||
mkdir -p $_DIR_FILE
|
||||
|
||||
$GEN_ENV > $1
|
||||
ok "ENVs generated... ${1}"
|
||||
}
|
||||
Reference in New Issue
Block a user