username
Get the username of the current user
Install
$ npm install --save username
Usage
const username = require('username');
username().then(username => {
console.log(username);
});
API
First tries to get the username from the LOGNAME
USER
LNAME
USERNAME
environment variables. Then falls back to $ id -un
on OS X / Linux and $ whoami
on Windows, in the rare case none of the environment variables are set. The result is cached.
username()
Returns a promise for the username.
username.sync()
Returns the username.
Related
License
MIT © Sindre Sorhus