Adds option to also set per project env values
This commit is contained in:
parent
4054508729
commit
aa282bff5d
@ -23,9 +23,15 @@ command -v jq >/dev/null 2>&1 || {
|
||||
|
||||
# main function ˘Ô≈ôﺣ
|
||||
function main() {
|
||||
# get the package details
|
||||
# check if we have project overides for the environment variables
|
||||
# shellcheck disable=SC2015
|
||||
[ -f "$VDM_PACKAGE_CONF_FILE" ] && getPackageDetails || {
|
||||
[ -f "$VDM_PACKAGE_CONF_FILE" ] && getProjectEnvironment || {
|
||||
echo >&2 "[error] We require config file with correct packaging details for $PROGRAM_NAME v${PROGRAM_V} to work, but it's not found in/at $VDM_PACKAGE_CONF_FILE. Aborting."
|
||||
clearMainEnv
|
||||
exit 1
|
||||
}
|
||||
# get the package details
|
||||
getPackageDetails || {
|
||||
echo >&2 "[error] We require config file with correct packaging details for $PROGRAM_NAME v${PROGRAM_V} to work, but it's not found in/at $VDM_PACKAGE_CONF_FILE. Aborting."
|
||||
clearMainEnv
|
||||
exit 1
|
||||
@ -78,10 +84,6 @@ function main() {
|
||||
|
||||
# set the package details
|
||||
function getPackageDetails() {
|
||||
# load the config data
|
||||
VDM_CONFIG_DATA=$(cat "$VDM_PACKAGE_CONF_FILE")
|
||||
# make sure we have package details
|
||||
if [[ "${VDM_CONFIG_DATA}" =~ '"package"' ]] && [[ "${VDM_CONFIG_DATA}" =~ '"files"' ]]; then
|
||||
# little information of progress
|
||||
_echo "[info] Loading the Package Details..."
|
||||
# make configuration globally available
|
||||
@ -117,13 +119,8 @@ function getPackageDetails() {
|
||||
getConfigValue 'VDM_UPDATE_SERVER' '.package.update_servers' || has_error=true
|
||||
# check if we have some errors already
|
||||
$has_error && return 13
|
||||
|
||||
# success
|
||||
return 0
|
||||
else
|
||||
# failed
|
||||
return 17
|
||||
fi
|
||||
}
|
||||
|
||||
# set the target repository details
|
||||
@ -1079,6 +1076,32 @@ function runUninstall() {
|
||||
fi
|
||||
}
|
||||
|
||||
# check if we have project overides for the environment variables
|
||||
function getProjectEnvironment() {
|
||||
# load the config data
|
||||
VDM_CONFIG_DATA=$(cat "$VDM_PACKAGE_CONF_FILE")
|
||||
# make sure we have package details
|
||||
if [[ "${VDM_CONFIG_DATA}" =~ '"package"' ]] && [[ "${VDM_CONFIG_DATA}" =~ '"files"' ]]; then
|
||||
# little information of progress
|
||||
_echo "[info] Loading the environment variables..."
|
||||
# make configuration globally available
|
||||
export VDM_CONFIG_DATA
|
||||
# get package code_name
|
||||
getConfigValue 'VDM_CODE_NAME' '.package.code_name'
|
||||
# the tmp path to the env of this project
|
||||
tmp_path="/home/$USER/.config/${PROGRAM_CODE}/.${VDM_CODE_NAME}"
|
||||
# shellcheck disable=SC1090
|
||||
[ -f "${tmp_path}" ] && source "${tmp_path}"
|
||||
# clear this tmp out
|
||||
unset tmp_path
|
||||
# success
|
||||
return 0
|
||||
else
|
||||
# failed
|
||||
return 17
|
||||
fi
|
||||
}
|
||||
|
||||
# update the script with the latest version
|
||||
function runUpdate() {
|
||||
# remove the current version
|
||||
@ -1194,7 +1217,7 @@ tmp_path="/home/$USER/.config/${PROGRAM_CODE}/.env"
|
||||
# if path not set try $PWD path
|
||||
[ -f "$tmp_path" ] || tmp_path="$PWD/.env"
|
||||
VDM_ENV_FILE_PATH="${VDM_ENV_FILE_PATH:-$tmp_path}"
|
||||
# car this tmp out
|
||||
# clear this tmp out
|
||||
unset tmp_path
|
||||
|
||||
# check if we have options
|
||||
|
Loading…
Reference in New Issue
Block a user