UNPKG

1.76 kBMarkdownView Raw
1# os-name [![Build Status](https://travis-ci.com/sindresorhus/os-name.svg?branch=master)](https://travis-ci.com/github/sindresorhus/os-name)
2
3> Get the name of the current operating system\
4> Example: `macOS Sierra`
5
6Useful for analytics and debugging.
7
8## Install
9
10```
11$ npm install os-name
12```
13
14## Usage
15
16```js
17const os = require('os');
18const osName = require('os-name');
19
20// On a macOS Sierra system
21
22osName();
23//=> 'macOS Sierra'
24
25osName(os.platform(), os.release());
26//=> 'macOS Sierra'
27
28osName('darwin', '14.0.0');
29//=> 'OS X Yosemite'
30
31osName('linux', '3.13.0-24-generic');
32//=> 'Linux 3.13'
33
34osName('win32', '6.3.9600');
35//=> 'Windows 8.1'
36```
37
38## API
39
40### osName(platform?, release?)
41
42By default, the name of the current operating system is returned.
43
44You can optionally supply a custom [`os.platform()`](https://nodejs.org/api/os.html#os_os_platform) and [`os.release()`](https://nodejs.org/api/os.html#os_os_release).
45
46Check out [`getos`](https://github.com/wblankenship/getos) if you need the Linux distribution name.
47
48## Contributing
49
50Production systems depend on this package for logging / tracking. Please be careful when introducing new output, and adhere to existing output format (whitespace, capitalization, etc.).
51
52## Related
53
54- [os-name-cli](https://github.com/sindresorhus/os-name-cli) - CLI for this module
55
56---
57
58<div align="center">
59 <b>
60 <a href="https://tidelift.com/subscription/pkg/npm-os-name?utm_source=npm-os-name&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
61 </b>
62 <br>
63 <sub>
64 Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
65 </sub>
66</div>