Adhere to XDG specification for cache dir.

This commit is contained in:
Anthony Sottile 2017-09-04 13:39:12 -07:00
parent ef8347cf2d
commit 0120af56a7
9 changed files with 50 additions and 17 deletions

View file

@ -29,9 +29,9 @@ def _get_default_directory():
`Store.get_default_directory` can be mocked in tests and
`_get_default_directory` can be tested.
"""
return os.environ.get(
'PRE_COMMIT_HOME',
os.path.join(os.path.expanduser('~'), '.pre-commit'),
return os.environ.get('PRE_COMMIT_HOME') or os.path.join(
os.environ.get('XDG_CACHE_HOME') or os.path.expanduser('~/.cache'),
'pre-commit',
)