https://github.com/martinheidegger/os-hostname
Simple node.js util that returns the hostname of the current system if evaluable.
https://github.com/martinheidegger/os-hostname
Last synced: 4 months ago
JSON representation
Simple node.js util that returns the hostname of the current system if evaluable.
- Host: GitHub
- URL: https://github.com/martinheidegger/os-hostname
- Owner: martinheidegger
- License: other
- Created: 2015-12-07T00:10:11.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-04-14T17:20:43.000Z (about 8 years ago)
- Last Synced: 2025-03-05T20:24:29.999Z (4 months ago)
- Language: JavaScript
- Homepage:
- Size: 17.6 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 46
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# os-hostname [](https://travis-ci.org/martinheidegger/os-hostname)
Simple [node.js](https://nodejs.org/) 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`](http://www.linfo.org/hostname_command.html) which is also available on [windows](https://technet.microsoft.com/en-us/library/bb490919.aspx).
# Usage
Install with:
```
$ npm i os-hostname --save
```and use it with:
```JavaScript
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:
```JavaScript
user.invalidate()
```## License
[ISC](https://en.wikipedia.org/wiki/ISC_license)
first version extracted from [osenv](https://github.com/npm/osenv)