Skip to content

Commit

Permalink
add support for macOS Sierra
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Jun 19, 2016
1 parent 312164f commit 7d4fb7c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
7 changes: 4 additions & 3 deletions index.js
@@ -1,6 +1,6 @@
'use strict';
var os = require('os');
var osxRelease = require('osx-release');
var macosRelease = require('macos-release');
var winRelease = require('win-release');

module.exports = function (platform, release) {
Expand All @@ -14,8 +14,9 @@ module.exports = function (platform, release) {
var id;

if (platform === 'darwin') {
id = osxRelease(release).name;
return 'OS X' + (id ? ' ' + id : '');
var prefix = Number(release.split('.')[0]) > 15 ? 'macOS' : 'OS X';
id = macosRelease(release).name;
return prefix + (id ? ' ' + id : '');
}

if (platform === 'linux') {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -37,8 +37,8 @@
"linux"
],
"dependencies": {
"macos-release": "^1.0.0",
"meow": "^3.7.0",
"osx-release": "^1.0.0",
"win-release": "^1.0.0"
},
"devDependencies": {
Expand Down
16 changes: 7 additions & 9 deletions readme.md
@@ -1,6 +1,7 @@
# os-name [![Build Status](https://travis-ci.org/sindresorhus/os-name.svg?branch=master)](https://travis-ci.org/sindresorhus/os-name)

> Get the name of the current operating system. Example: `OS X Mavericks`
> Get the name of the current operating system<br>
> Example: `macOS Sierra`
Useful for analytics and debugging.

Expand All @@ -18,25 +19,22 @@ $ npm install --save os-name
const os = require('os');
const osName = require('os-name');

// on an OS X Mavericks system
// on a macOS Sierra system

osName();
//=> 'OS X Mavericks'
//=> 'macOS Sierra'

osName(os.platform(), os.release());
//=> 'OS X Mavericks'
//=> 'macOS Sierra'

osName(os.platform());
//=> 'OS X'
osName('darwin', '14.0.0');
//=> 'OS X Yosemite'

osName('linux', '3.13.0-24-generic');
//=> 'Linux 3.13'

osName('win32', '6.3.9600');
//=> 'Windows 8.1'

osName('win32');
// 'Windows'
```


Expand Down
2 changes: 2 additions & 0 deletions test.js
Expand Up @@ -3,7 +3,9 @@ import m from './';

test(t => {
t.true(m().length > 0);
t.is(m('darwin', '16.0.0'), 'macOS Sierra');
t.is(m('darwin', '14.0.0'), 'OS X Yosemite');
t.is(m('darwin', '99.0.0'), 'macOS');
t.is(m('linux', '3.13.0-24-generic'), 'Linux 3.13');
t.is(m('win32', '5.1.2600'), 'Windows XP');
t.is(m('win32'), 'Windows');
Expand Down

0 comments on commit 7d4fb7c

Please sign in to comment.