-
-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor internals #12
Conversation
- determining `defaultNpmPrefix` from `process.execPath` exclusively - moving %APPDATA% and Homebrew related stuff to `getGlobalNpmrc` that returns path to global config - determining global prefix by reading global config
@vladimyr Could use your thoughts in sindresorhus/resolve-global#3 (comment) |
// @TiagoDanin @boneskull Can you help review? |
I'll give my best although I'm not yarn user and my daily driver is macos. |
Btw I did some experiments and figured out that npm has following order of preference when it comes to determining
|
@sindresorhus What I did here are mostly cosmetic changes ready for merge but it doesn't give us any benefit regarding #13 After investigating #13 I figured out that more thorough refactor is needed which I already started doing (locally) and I intend to finish this weekend. Sorry about late response, I'm not able to squeeze enough opensource time out of my schedule lately 🙃 |
Ok. Great. I'll merge this then to keep your upcoming PR focused on fixing #13. |
This PR brings in bunch of internal changes:
defaultNpmPrefix
eagerlyThat's pretty much self explanatory because we might not need it in case
prefix
is being overridden by env or user config.defaultNpmPrefix
fromprocess.execPath
exclusivelyIn all other cases we should rely on found config file (user/global) and value written inside.
%APPDATA%
(windows) and Homebrew related stuff togetGlobalNpmrc
This is not determining global npm prefix but rather determining location of global
npmrc
config which should then be used to determine global prefix.To summarize:
env
it is aenvPrefix
homePrefix
determined from homedir'snpmrc
%APPDATA%/npm/etc/npmrc
on Windows, or Homebrew's$(brew --prefix)/lib/node_modules/npm/npmrc
) it isglobalPrefix
determined fromglobalNpmrc
process.execPath