os-hostname
v1.1.3
Published
Platform aware tool to get the current hostname using environment variables and falls back to the system command hostname.
Downloads
69
Maintainers
Readme
os-hostname
Simple node.js util that returns the hostname of the current system if evaluable.
On windows this util is aware of the domain using the COMPUTERNAME
environment variable.
On other systems it uses the HOSTNAME
environment variable.
If the environment variable is not given or empty on other systems it will fallback to hostname
which is also available on windows.
Usage
Install with:
$ npm i os-hostname --save
and use it with:
var hostname = require('os-hostname')
hostname(function (err, hname) {
console.log(hname)
})
cheers.
Caching & Invalidation
By default the user is cached for 10 minutes it is possible to invalidate the cache using:
user.invalidate()
License
first version extracted from osenv