Closed killerfurbel closed 6 years ago
Hi! Thank you for the pull request and detailed explanation of how it works! Overall the approach of using of rc
looks good to me. I will check the code soon.
Thank you @killerfurbel !
Published as 1.6.0
on npm
and GitHub https://github.com/delfrrr/npm-consider/releases
I got across this when checking one of my projects which contains modules from SAP (@sap/ prefix), those modules are hosted on npm.sap.com. To be able to
npm install
those modules, you need to add this setting to the npm config (for example, to the user config):@sap:registry = "https://npm.sap.com"
see https://docs.npmjs.com/misc/scope#associating-a-scope-with-a-registry
I was looking for a way to get these npm settings and came across npm-conf, but this module mainly relied on a dependency config-chain to get the configuration. I checked this one and it said:
So I went with rc, which does the job.
rc has the following dependencies:
Now rc is used to get the config (global and project specific), the module key is checked for a scope using a regex (starting with @, containing a /). If there is a scope, try to use the registry url of the scope, fallback to the official registry.npmjs.org
npm config is fine when the scoped registry URL does not end with a /, but since we just concaternate the module name, we need to add a / to the url if it doesn't end with one...