diff options
Diffstat (limited to 'deps/npm/lib/whoami.js')
-rw-r--r-- | deps/npm/lib/whoami.js | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/deps/npm/lib/whoami.js b/deps/npm/lib/whoami.js index 121c4336ae..42cede1b82 100644 --- a/deps/npm/lib/whoami.js +++ b/deps/npm/lib/whoami.js @@ -14,6 +14,14 @@ function whoami (args, silent, cb) { var registry = npm.config.get("registry") if (!registry) return cb(new Error("no default registry set")) + function noUser () { + // At this point, if they have a credentials object, it doesn't have a + // token or auth in it. Probably just the default registry. + var msg = "Not authed. Run 'npm adduser'" + if (!silent) console.log(msg) + cb(null, msg) + } + var auth = npm.config.getCredentialsByURI(registry) if (auth) { if (auth.username) { @@ -23,6 +31,7 @@ function whoami (args, silent, cb) { else if (auth.token) { return npm.registry.whoami(registry, { auth : auth }, function (er, username) { if (er) return cb(er) + if (!username) return noUser() if (!silent) console.log(username) cb(null, username) @@ -30,10 +39,5 @@ function whoami (args, silent, cb) { } } - // At this point, if they have a credentials object, it doesn't - // have a token or auth in it. Probably just the default - // registry. - var msg = "Not authed. Run 'npm adduser'" - if (!silent) console.log(msg) - process.nextTick(cb.bind(this, null, msg)) + process.nextTick(noUser) } |