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. Example: `OS X Mavericks`
|
4 |
|
5 | Useful for analytics and debugging.
|
6 |
|
7 |
|
8 | ## Install
|
9 |
|
10 | ```sh
|
11 | $ npm install --save os-name
|
12 | ```
|
13 |
|
14 |
|
15 | ## Usage
|
16 |
|
17 | ```js
|
18 | var os = require('os');
|
19 | var osName = require('os-name');
|
20 |
|
21 | // on an OS X Mavericks system
|
22 |
|
23 | osName();
|
24 | //=> OS X Mavericks
|
25 |
|
26 | osName(os.platform(), os.release());
|
27 | //=> OS X Mavericks
|
28 |
|
29 | osName(os.platform());
|
30 | //=> OS X
|
31 |
|
32 | osName('linux', '3.13.0-24-generic');
|
33 | //=> Linux 3.13
|
34 |
|
35 | osName('win32', '6.3.9600');
|
36 | //=> Windows 8.1
|
37 |
|
38 | osName('win32');
|
39 | // Windows
|
40 | ```
|
41 |
|
42 |
|
43 | ## API
|
44 |
|
45 | ### osName([platform, release])
|
46 |
|
47 | By default the name of the current operating system is returned.
|
48 |
|
49 | 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).
|
50 |
|
51 | Check out [getos](https://github.com/wblankenship/getos) if you need the Linux distribution name.
|
52 |
|
53 |
|
54 | ## CLI
|
55 |
|
56 | ```sh
|
57 | $ npm install --global os-name
|
58 | ```
|
59 |
|
60 | ```sh
|
61 | $ os-name --help
|
62 |
|
63 | Example
|
64 | os-name
|
65 | OS X Mavericks
|
66 | ```
|
67 |
|
68 |
|
69 | ## Contributing
|
70 |
|
71 | 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.).
|
72 |
|
73 |
|
74 | ## License
|
75 |
|
76 | MIT © [Sindre Sorhus](http://sindresorhus.com)
|