diff options
Diffstat (limited to 'deps/npm/node_modules/npm-registry-client/lib/whoami.js')
-rw-r--r-- | deps/npm/node_modules/npm-registry-client/lib/whoami.js | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/deps/npm/node_modules/npm-registry-client/lib/whoami.js b/deps/npm/node_modules/npm-registry-client/lib/whoami.js new file mode 100644 index 000000000..ffa7bd704 --- /dev/null +++ b/deps/npm/node_modules/npm-registry-client/lib/whoami.js @@ -0,0 +1,15 @@ +module.exports = whoami + +var url = require("url") + +function whoami (uri, cb) { + if (!this.conf.getCredentialsByURI(uri)) { + return cb(new Error("Must be logged in to see who you are")) + } + + this.request("GET", url.resolve(uri, "whoami"), null, function (er, userdata) { + if (er) return cb(er) + + cb(null, userdata.username) + }) +} |