Works on OS X and Linux.
$ npm install --save passwd-user
var passwdUser = require('passwd-user');
passwdUser.sync('sindresorhus');
/*
{
username: 'sindresorhus',
password: '*',
uid: 501,
gid: 20,
fullname: 'Sindre Sorhus',
homedir: '/home/sindresorhus',
shell: '/bin/zsh'
}
*/
// or
passwdUser.sync(501);
// or
passwdUser.sync(process.getuid());
Accepts a username
or uid
number and returns an object with:
username
password
uid
: user IDgid
: group IDfullname
: name of userhomedir
: home directoryshell
: default shell
username
- get the users username (cross-platform)fullname
- get the users fullname (cross-platform)
MIT © Sindre Sorhus