mirror of
https://github.com/Keychron/qmk_firmware.git
synced 2024-11-22 08:27:56 +06:00
Resolve home directory in userspace config (#23730)
This commit is contained in:
parent
eb5172f4b5
commit
340be4bae3
|
@ -12,29 +12,29 @@ from qmk.json_encoders import UserspaceJSONEncoder
|
||||||
|
|
||||||
|
|
||||||
def qmk_userspace_paths():
|
def qmk_userspace_paths():
|
||||||
test_dirs = {}
|
test_dirs = set()
|
||||||
|
|
||||||
# If we're already in a directory with a qmk.json and a keyboards or layouts directory, interpret it as userspace
|
# If we're already in a directory with a qmk.json and a keyboards or layouts directory, interpret it as userspace
|
||||||
if environ.get('ORIG_CWD') is not None:
|
if environ.get('ORIG_CWD') is not None:
|
||||||
current_dir = Path(environ['ORIG_CWD'])
|
current_dir = Path(environ['ORIG_CWD'])
|
||||||
while len(current_dir.parts) > 1:
|
while len(current_dir.parts) > 1:
|
||||||
if (current_dir / 'qmk.json').is_file():
|
if (current_dir / 'qmk.json').is_file():
|
||||||
test_dirs[current_dir] = True
|
test_dirs.add(current_dir)
|
||||||
current_dir = current_dir.parent
|
current_dir = current_dir.parent
|
||||||
|
|
||||||
# If we have a QMK_USERSPACE environment variable, use that
|
# If we have a QMK_USERSPACE environment variable, use that
|
||||||
if environ.get('QMK_USERSPACE') is not None:
|
if environ.get('QMK_USERSPACE') is not None:
|
||||||
current_dir = Path(environ['QMK_USERSPACE'])
|
current_dir = Path(environ['QMK_USERSPACE']).expanduser()
|
||||||
if current_dir.is_dir():
|
if current_dir.is_dir():
|
||||||
test_dirs[current_dir] = True
|
test_dirs.add(current_dir)
|
||||||
|
|
||||||
# If someone has configured a directory, use that
|
# If someone has configured a directory, use that
|
||||||
if cli.config.user.overlay_dir is not None:
|
if cli.config.user.overlay_dir is not None:
|
||||||
current_dir = Path(cli.config.user.overlay_dir)
|
current_dir = Path(cli.config.user.overlay_dir).expanduser().resolve()
|
||||||
if current_dir.is_dir():
|
if current_dir.is_dir():
|
||||||
test_dirs[current_dir] = True
|
test_dirs.add(current_dir)
|
||||||
|
|
||||||
return list(test_dirs.keys())
|
return list(test_dirs)
|
||||||
|
|
||||||
|
|
||||||
def qmk_userspace_validate(path):
|
def qmk_userspace_validate(path):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user