fix(npm-info): support basic auth

This commit is contained in:
Christoph Witzko
2015-05-27 19:05:06 +02:00
parent d0032de737
commit 25828960bc
+9 -5
View File
@@ -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) {