npm-whoami
v1.1.4
Published
Find the logged in npm user from the cli
Downloads
3,341
Readme
npm-whoami
Finds the npm username of the logged in npm user.
Usage
var npmWhoami = require('npm-whoami');
npmWhoami(function(err, username) {
console.log(username);
// james.talmage
});
API
npmWhoami([options, ] callback)
callback (err, username)
Required
Type: function (err, username)
Called with the npm username, or an error if it can not be found.
options
Optional
Type: object | string | number
If a string
, it will be treated as the registry url.
If a number
, it will be used as the timeout value.
You can pass an object hash if you need both values.
options.registry
Optional
Type: string
Will use the --registry
flag to set an alternate registry url.
options.timeout
Optional
Type: number
Sets a maximum time to wait for a response from the server (in ms). Default is 10,000 ms.
npmWhoami({
registry: 'http://localhost:55550',
timeout: 4000
}, cb);
npmWhoami.sync([options])
Same available options
as the async version.
Returns a string username, or throws if the user is not logged in.
This synchronous function is not available on v0.10.x
or earlier.
License
MIT © James Talmage