diff --git a/loopy b/loopy index 27709bf..0aef6aa 100755 --- a/loopy +++ b/loopy @@ -1,6 +1,7 @@ #!/bin/bash ROOT_PATH="${LOOPY_ROOT_PATH:-$(pwd)}" +export ORIGINAL_DIR=$(pwd) pushd "$ROOT_PATH" > /dev/null PYTHONPATH=.:src python ./cmd/loopy.py "$@" diff --git a/src/cli/commands/utils.py b/src/cli/commands/utils.py index 1a0c41c..b2f1382 100644 --- a/src/cli/commands/utils.py +++ b/src/cli/commands/utils.py @@ -142,9 +142,11 @@ def parse_key_value_pairs(ctx, param, value): def load_env_file_if_exist(file): additional_vars = {} if file is not None: - if os.path.exists(file): - with open(file, "r") as file: - for line in file: + original_dir = os.environ.get("ORIGINAL_DIR", os.getcwd()) + input_path = os.path.normpath(os.path.join(original_dir, file)) + if os.path.exists(input_path): + with open(input_path, "r") as f: + for line in f: if not line.strip() or line.startswith("#"): # Skip # part continue key, value = line.strip().split("=") @@ -153,7 +155,7 @@ def load_env_file_if_exist(file): else: additional_vars[key] = value else: - logger.error(f"File({file}) does not exist") + logger.error(f"File({input_path}) does not exist") exit(1) return additional_vars