Adds correct order of env file loading, from local to global.

This commit is contained in:
Llewellyn van der Merwe 2023-02-14 15:41:51 +02:00
parent f6291bf8ba
commit 9012c5b541
Signed by: Llewellyn
GPG Key ID: A9201372263741E7
2 changed files with 13 additions and 5 deletions

View File

@ -29,15 +29,23 @@ Usage: octojpack [OPTION...]
Packager url
example: octojpack -pu="https://git.vdm.dev/"
======================================================
-md | --main-dir=<path>
load the main working directory
example: octojpack --main-dir=/src
======================================================
-e | --env=<file>
load the environment variables file
example: octojpack --env=/src/.env
======================================================
--conf | --config=<path>
--conf | --config=<path/url>
load the configuration for the package in json format
file-example: src/example.json
example: octojpack --config=config.json
======================================================
-ld | --licence-dir=<path>
load the licence directory
example: octojpack --licence-dir=/src/licence
======================================================
-t | --token=<access_token>
load the global token
example: octojpack --token=xxxxxxxxxxxxxxxxxxxxxxxxx
@ -67,7 +75,7 @@ Usage: octojpack [OPTION...]
example: octojpack -h
example: octojpack --help
======================================================
Octojpack v1.0
Octojpack
======================================================
```

View File

@ -1277,11 +1277,11 @@ tmp_path="${VDM_MAIN_DIR}/licenses"
VDM_LICENSE_DIR="${VDM_LICENSE_DIR:-$tmp_path}"
# the environment file variables path
tmp_path="/home/$USER/.config/${PROGRAM_CODE}/.env"
tmp_path="$PWD/.env_${PROGRAM_CODE}"
# if file not set try $PWD path
[ -f "$tmp_path" ] || tmp_path="$PWD/.env_${PROGRAM_CODE}"
# if file not set try $VDM_MAIN_DIR path
[ -f "$tmp_path" ] || tmp_path="$VDM_MAIN_DIR/.env_${PROGRAM_CODE}"
# if file not set try $VDM_MAIN_DIR path
[ -f "$tmp_path" ] || tmp_path="/home/$USER/.config/${PROGRAM_CODE}/.env"
# ALWAYS USE GLOBAL IF SET
VDM_ENV_FILE_PATH="${VDM_ENV_FILE_PATH:-$tmp_path}"