1 | # os-name [![Build Status](https://travis-ci.org/sindresorhus/os-name.svg?branch=master)](https://travis-ci.org/sindresorhus/os-name)
|
2 |
|
3 | > Get the name of the current operating system<br>
|
4 | > Example: `macOS Sierra`
|
5 |
|
6 | Useful for analytics and debugging.
|
7 |
|
8 |
|
9 | ## Install
|
10 |
|
11 | ```
|
12 | $ npm install --save os-name
|
13 | ```
|
14 |
|
15 |
|
16 | ## Usage
|
17 |
|
18 | ```js
|
19 | const os = require('os');
|
20 | const osName = require('os-name');
|
21 |
|
22 | // on a macOS Sierra system
|
23 |
|
24 | osName();
|
25 | //=> 'macOS Sierra'
|
26 |
|
27 | osName(os.platform(), os.release());
|
28 | //=> 'macOS Sierra'
|
29 |
|
30 | osName('darwin', '14.0.0');
|
31 | //=> 'OS X Yosemite'
|
32 |
|
33 | osName('linux', '3.13.0-24-generic');
|
34 | //=> 'Linux 3.13'
|
35 |
|
36 | osName('win32', '6.3.9600');
|
37 | //=> 'Windows 8.1'
|
38 | ```
|
39 |
|
40 |
|
41 | ## API
|
42 |
|
43 | ### osName([platform, release])
|
44 |
|
45 | By default the name of the current operating system is returned.
|
46 |
|
47 | You can optionally supply a custom [`os.platform()`](http://nodejs.org/api/os.html#os_os_platform) and [`os.release()`](http://nodejs.org/api/os.html#os_os_release).
|
48 |
|
49 | Check out [getos](https://github.com/wblankenship/getos) if you need the Linux distribution name.
|
50 |
|
51 |
|
52 | ## Contributing
|
53 |
|
54 | Production systems depend on this package for logging / tracking. Please be careful when introducing new output, and adhere to existing output format (whitespace, capitalization, etc.).
|
55 |
|
56 |
|
57 | ## Related
|
58 |
|
59 | - [os-name-cli](https://github.com/sindresorhus/os-name-cli) - CLI for this module
|
60 |
|
61 |
|
62 | ## License
|
63 |
|
64 | MIT © [Sindre Sorhus](https://sindresorhus.com)
|