username
Get the username of the current user
Install
$ npm install --save username
Usage
var username = require('username');
username(function (err, username) {
console.log(username);
});
username.sync();
API
Tries to get the username from the LOGNAME
USER
LNAME
USERNAME
environment variables. The result is cached.
username(callback)
Falls back to id -un
on OS X / Linux and whoami
on Windows in the rare case none of the environment variables are set.
callback(err, username)
username.sync()
CLI
You can also use it as a CLI app by installing it globally:
$ npm install --global username
Usage
$ username --help
Usage
$ username
sindresorhus
License
MIT © Sindre Sorhus