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,
|
npmconf.load,
|
||||||
function (conf, callback) {
|
function (conf, callback) {
|
||||||
var cred = conf.getCredentialsByURI(registry)
|
var cred = conf.getCredentialsByURI(registry)
|
||||||
callback(null, {
|
var reqopts = {
|
||||||
url: registry + pkgName.replace(/\//g, '%2F'),
|
url: registry + pkgName.replace(/\//g, '%2F'),
|
||||||
headers: {
|
headers: {}
|
||||||
'Authorization': cred.token ? 'Bearer ' + cred.token : null
|
}
|
||||||
}
|
if (cred.token) {
|
||||||
})
|
reqopts.headers.Authorization = 'Bearer ' + cred.token
|
||||||
|
} else if (cred.auth) {
|
||||||
|
reqopts.headers.Authorization = 'Basic ' + cred.auth
|
||||||
|
}
|
||||||
|
callback(null, reqopts)
|
||||||
},
|
},
|
||||||
request,
|
request,
|
||||||
function (response, body, callback) {
|
function (response, body, callback) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user