npm-whoami
DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/npm-whoami package

1.1.4 • Public • Published

npm-whoami

Finds the npm username of the logged in npm user.

Build Status Coverage Status Code Climate Dependency Status devDependency Status

NPM

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

Readme

Keywords

Package Sidebar

Install

npm i npm-whoami

Weekly Downloads

187

Version

1.1.4

License

MIT

Last publish

Collaborators

  • jamestalmage