| Server IP : 185.11.201.71 / Your IP : 192.168.7.18 Web Server : Apache/2.4.29 (Ubuntu) System : Linux tech-virtual-machine 4.15.0-213-generic #224-Ubuntu SMP Mon Jun 19 13:30:12 UTC 2023 x86_64 User : tech ( 1000) PHP Version : 7.4.28 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : OFF | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/share/npm/lib/utils/ |
Upload File : |
var url = require('url')
var log = require('npmlog')
var npa = require('npm-package-arg')
module.exports = mapToRegistry
function mapToRegistry (name, config, cb) {
log.silly('mapToRegistry', 'name', name)
var registry
// the name itself takes precedence
var data = npa(name)
if (data.scope) {
// the name is definitely scoped, so escape now
name = name.replace('/', '%2f')
log.silly('mapToRegistry', 'scope (from package name)', data.scope)
registry = config.get(data.scope + ':registry')
if (!registry) {
log.verbose('mapToRegistry', 'no registry URL found in name for scope', data.scope)
}
}
// ...then --scope=@scope or --scope=scope
var scope = config.get('scope')
if (!registry && scope) {
// I'm an enabler, sorry
if (scope.charAt(0) !== '@') scope = '@' + scope
log.silly('mapToRegistry', 'scope (from config)', scope)
registry = config.get(scope + ':registry')
if (!registry) {
log.verbose('mapToRegistry', 'no registry URL found in config for scope', scope)
}
}
// ...and finally use the default registry
if (!registry) {
log.silly('mapToRegistry', 'using default registry')
registry = config.get('registry')
}
log.silly('mapToRegistry', 'registry', registry)
var auth = config.getCredentialsByURI(registry)
// normalize registry URL so resolution doesn't drop a piece of registry URL
var normalized = registry.slice(-1) !== '/' ? registry + '/' : registry
var uri = url.resolve(normalized, name)
log.silly('mapToRegistry', 'uri', uri)
cb(null, uri, auth, normalized)
}