$ cnpm install os-user
Simple node.js util that returns the user currently running on the system.
On windows this util is aware of the domain using the USERDOMAIN
and USERNAME
variable.
On other systems it uses the USER
environment variable. If the USER
is not given or empty on other systems it will fallback to whoami
.
Install with:
$ npm i os-user --save
and use it with:
var user = require('os-user')
user(function (err, usr) {
console.log(usr)
})
cheers.
By default the user is cached for 10 minutes it is possible to invalidate the cache using:
user.invalidate()
first version extracted from osenv
Copyright 2014 - 2017 © taobao.org |