diff --git a/.gitignore b/.gitignore index 798a4d51..ea615df1 100755 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,7 @@ demo/ **/__pycache__ *.egg-info/ -.venv \ No newline at end of file +.venv +venv +.env + diff --git a/FABulous/FABulous.py b/FABulous/FABulous.py index 5e6a4631..47da71b4 100644 --- a/FABulous/FABulous.py +++ b/FABulous/FABulous.py @@ -97,6 +97,7 @@ def setup_global_env_vars(args: argparse.Namespace) -> None: logger.info(f"FAB_ROOT set to {fabulousRoot}") # Load the .env file and make env variables available globally + fabDir = Path(os.getenv("FAB_ROOT")) if args.globalDotEnv: gde = Path(args.globalDotEnv) if gde.is_file(): @@ -107,12 +108,15 @@ def setup_global_env_vars(args: argparse.Namespace) -> None: logger.info(f"Load global .env file from {gde.joinpath('.env')}") else: logger.warning(f"No global .env file found at {gde}") + elif fabDir.joinpath(".env").exists() and fabDir.joinpath(".env").is_file(): + load_dotenv(fabDir.joinpath(".env")) + logger.info(f"Loaded global .env file from {fabulousRoot}/.env") elif ( - Path(os.getenv("FAB_ROOT")).joinpath(".env").exists() - and Path(os.getenv("FAB_ROOT")).joinpath(".env").is_file() + fabDir.parent.joinpath(".env").exists() + and fabDir.parent.joinpath(".env").is_file() ): - load_dotenv(Path(os.getenv("FAB_ROOT")).joinpath(".env")) - logger.info(f"Loaded global .env file from {fabulousRoot}/.env") + load_dotenv(fabDir.parent.joinpath(".env")) + logger.info(f"Loaded global .env file from {fabDir.parent.joinpath('.env')}") else: logger.warning("No global .env file found") @@ -141,6 +145,12 @@ def setup_project_env_vars(args: argparse.Namespace) -> None: elif fabDir.joinpath(".env").exists() and fabDir.joinpath(".env").is_file(): load_dotenv(fabDir.joinpath(".env")) logger.info(f"Loaded project .env file from {fabDir}/.env')") + elif ( + fabDir.parent.joinpath(".env").exists() + and fabDir.parent.joinpath(".env").is_file() + ): + load_dotenv(fabDir.parent.joinpath(".env")) + logger.info(f"Loaded project .env file from {fabDir.parent.joinpath('.env')}") else: logger.warning("No project .env file found")