Updated config to use Application Support on macOS

NUSGet will now also create .config if it doesn't exist on Linux, though I really can't see that ever happening.
This commit is contained in:
Campbell 2025-06-05 08:50:51 -04:00
parent 27680626fa
commit dd189f31b1
Signed by: NinjaCheetah
GPG Key ID: 39C2500E1778B156

View File

@ -4,15 +4,20 @@
import os import os
import json import json
import pathlib import pathlib
import platform
def get_config_file() -> pathlib.Path: def get_config_file() -> pathlib.Path:
config_dir = pathlib.Path(os.path.join( if platform.system() == "Windows":
os.environ.get('APPDATA') or config_dir = pathlib.Path(os.environ.get('APPDATA'), "NUSGet")
os.environ.get('XDG_CONFIG_HOME') or elif platform.system() == "Darwin":
os.path.join(os.environ['HOME'], '.config'), config_dir = pathlib.Path(os.environ['HOME'], "Library", "Application Support", "NUSGet")
"NUSGet" else:
)) if os.environ.get('XDG_CONFIG_HOME'):
config_dir.mkdir(exist_ok=True) config_dir = pathlib.Path(os.environ.get('XDG_CONFIG_HOME'), "NUSGet")
else:
config_dir = pathlib.Path(os.environ['HOME'], ".config", "NUSGet")
config_dir.mkdir(exist_ok=True, parents=True)
return config_dir.joinpath("config.json") return config_dir.joinpath("config.json")