UNPKG

1.43 kBMarkdownView Raw
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
5Useful 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
18var os = require('os');
19var osName = require('os-name');
20
21// on an OS X Mavericks system
22
23osName();
24//=> OS X Mavericks
25
26osName(os.platform(), os.release());
27//=> OS X Mavericks
28
29osName(os.platform());
30//=> OS X
31
32osName('linux', '3.13.0-24-generic');
33//=> Linux 3.13
34
35osName('win32', '6.3.9600');
36//=> Windows 8.1
37
38osName('win32');
39// Windows
40```
41
42
43## API
44
45### osName([platform, release])
46
47By default the name of the current operating system is returned.
48
49You 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
51Check 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
71Production 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
76MIT © [Sindre Sorhus](http://sindresorhus.com)