rc9
rc9 copied to clipboard
Fallback to `$HOME/.config` if `$XDG_CONFIG_HOME` is not set
Just a minor nitpick--as someone with an extremely cluttered /home/{name}
directory from all of the config files creates by various applications, I think it would be a better idea to recommend the use of /home/{name}/.config
here.
I'm not sure about the convention for MacOS and Windows, but hopefully they also have a standard location for applications to create config files.
https://github.com/unjs/rc9/blob/b9ab9e9c79873956525a97ac4202280f90824187/README.md?plain=1#L69-L79
Thanks for making issue. Honestly i tend to agree with you. It is always easier to find relevant config files from ~/.config
(also cache from ~/.cache
etc).
Main tricky part is how we can make a change without breaking changes i guess or reduce the surface as rc9 is used internally in other projects such as c12 > nitro > nuxt, etc.
I'm not very acquainted with the codebase, but at first glance it seems like readUser
, writeUser
, and updateUser
can be deprecated in favor of new readConfig
, writeConfig
, and updateConfig
methods. These would rely on $XDG_CONFIG_HOME
rather than $HOME
.
Whether to fall back to $HOME
if $XDG_CONFIG_HOME
doesn't exist or to create $XDG_CONFIG_HOME
properly based on the OS is another question.
Nice idea to introduce new utils, we could call them *userConfig()
I know Vercel CLI is using https://www.npmjs.com/package/xdg-app-paths for example to get the path
The git CLI calls the different locations global (~/.gitconfig and ~/.config/git/config), system (config under /etc) and local (config from the current directory). For global it simply reads both files which would be backwards compatible and writes to the latter location if it already exists and the former otherwise.