rename to FLASK_SKIP_DOTENV, add docs, test

This commit is contained in:
David Lord 2018-04-28 08:07:53 -07:00
parent bac5d6b9f4
commit 5965cb7e1c
No known key found for this signature in database
GPG key ID: 7A1C87E3F5BC42A8
4 changed files with 50 additions and 7 deletions

View file

@ -28,7 +28,7 @@ from werkzeug.utils import import_string
from . import __version__
from ._compat import getargspec, iteritems, reraise, text_type
from .globals import current_app
from .helpers import get_debug_flag, get_env
from .helpers import get_debug_flag, get_env, get_load_dotenv
try:
import dotenv
@ -544,10 +544,7 @@ class FlaskGroup(AppGroup):
# script that is loaded here also attempts to start a server.
os.environ['FLASK_RUN_FROM_CLI'] = 'true'
val = os.environ.get('FLASK_DONT_LOAD_ENV')
load_dotenv = not val or val in ('0', 'false', 'no')
if self.load_dotenv and load_dotenv:
if get_load_dotenv(self.load_dotenv):
load_dotenv()
obj = kwargs.get('obj')
@ -586,12 +583,11 @@ def load_dotenv(path=None):
.. versionadded:: 1.0
"""
if dotenv is None:
if path or os.path.exists('.env') or os.path.exists('.flaskenv'):
click.secho(
' * Tip: There are .env files present.'
' Do "pip install python-dotenv" to use them',
' Do "pip install python-dotenv" to use them.',
fg='yellow')
return