Linux ip-172-26-7-228 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64
Your IP : 18.188.114.150
module.exports = logout
var dezalgo = require('dezalgo')
var log = require('npmlog')
var npm = require('./npm.js')
var mapToRegistry = require('./utils/map-to-registry.js')
logout.usage = 'npm logout [--registry=<url>] [--scope=<@scope>]'
function logout (args, cb) {
cb = dezalgo(cb)
mapToRegistry('/', npm.config, function (err, uri, auth, normalized) {
if (err) return cb(err)
if (auth.token) {
log.verbose('logout', 'clearing session token for', normalized)
npm.registry.logout(normalized, { auth: auth }, function (err) {
if (err) return cb(err)
npm.config.clearCredentialsByURI(normalized)
npm.config.save('user', cb)
})
} else if (auth.username || auth.password) {
log.verbose('logout', 'clearing user credentials for', normalized)
npm.config.clearCredentialsByURI(normalized)
npm.config.save('user', cb)
} else {
cb(new Error(
'Not logged in to', normalized + ',', "so can't log out."
))
}
})
}
|