fix(install): try with HOME env dir if no npmrc found in XDG_CONFIG_HOME
What does this PR do?
In github CI workflows, the XDG_CONFIG_HOME is set to /home/runner/.config.
When using .npmrc in HOME (the normal behavior), the current implementation will never look there if XDG_CONFIG_HOME is set and as there is no .npmrc in /home/runner/.config, we cannot install or publish private packages.
The workaround is to copying the $HOME/.npmrc locally or worst unsetting XDG_CONFIG_HOME but could break others programs.. I think this should work out of the box.
This PR will check if .npmrc exists in both places $XDG_CONFIG_HOME/.npmrc then $HOME/.npmrc.
Previously, the code used XDG_CONFIG_HOME.get() orelse HOME.get() which meant if XDG_CONFIG_HOME was defined but no .npmrc existed there, it would never fall back to check HOME/.npmrc.
How did you verify your code works?
Setup: XDG_CONFIG_HOME is set but .npmrc is in HOME
export XDG_CONFIG_HOME=/tmp/xdg-config
export HOME=/tmp/home
mkdir -p $XDG_CONFIG_HOME $HOME
echo "registry=https://custom.registry.example/" > $HOME/.npmrc
# Before: would not find the config
# After: correctly loads from $HOME/.npmrc and be able to install private package
bun install