Specify config with environment variable YAMLLINT_CONFIG_FILE

Add option to specify config file with environment variable.
Add test case.
This commit is contained in:
Will Badart
2020-04-28 02:13:32 -07:00
committed by GitHub
parent a54cbce1b6
commit 94c0416f6b
2 changed files with 24 additions and 1 deletions

View File

@@ -144,8 +144,11 @@ def run(argv=None):
args = parser.parse_args(argv)
if 'YAMLLINT_CONFIG_FILE' in os.environ:
user_global_config = os.path.expanduser(
os.environ['YAMLLINT_CONFIG_FILE'])
# User-global config is supposed to be in ~/.config/yamllint/config
if 'XDG_CONFIG_HOME' in os.environ:
elif 'XDG_CONFIG_HOME' in os.environ:
user_global_config = os.path.join(
os.environ['XDG_CONFIG_HOME'], 'yamllint', 'config')
else: