fix(npm-info): support basic auth
This commit is contained in:
parent
d0032de737
commit
25828960bc
@ -10,12 +10,16 @@ module.exports = function (pkgName, cb) {
|
||||
npmconf.load,
|
||||
function (conf, callback) {
|
||||
var cred = conf.getCredentialsByURI(registry)
|
||||
callback(null, {
|
||||
var reqopts = {
|
||||
url: registry + pkgName.replace(/\//g, '%2F'),
|
||||
headers: {
|
||||
'Authorization': cred.token ? 'Bearer ' + cred.token : null
|
||||
}
|
||||
})
|
||||
headers: {}
|
||||
}
|
||||
if (cred.token) {
|
||||
reqopts.headers.Authorization = 'Bearer ' + cred.token
|
||||
} else if (cred.auth) {
|
||||
reqopts.headers.Authorization = 'Basic ' + cred.auth
|
||||
}
|
||||
callback(null, reqopts)
|
||||
},
|
||||
request,
|
||||
function (response, body, callback) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user