os-name
Advanced tools
Comparing version 2.0.1 to 3.0.0
31
index.js
'use strict'; | ||
var os = require('os'); | ||
var macosRelease = require('macos-release'); | ||
var winRelease = require('win-release'); | ||
const os = require('os'); | ||
const macosRelease = require('macos-release'); | ||
const winRelease = require('windows-release'); | ||
module.exports = function (platform, release) { | ||
module.exports = (platform, release) => { | ||
if (!platform && release) { | ||
@@ -12,9 +12,12 @@ throw new Error('You can\'t specify a `release` without specifying `platform`'); | ||
platform = platform || os.platform(); | ||
release = release || os.release(); | ||
var id; | ||
let id; | ||
if (platform === 'darwin') { | ||
var prefix = Number(release.split('.')[0]) > 15 ? 'macOS' : 'OS X'; | ||
id = macosRelease(release).name; | ||
if (!release && os.platform() === 'darwin') { | ||
release = os.release(); | ||
} | ||
const prefix = release ? (Number(release.split('.')[0]) > 15 ? 'macOS' : 'OS X') : 'macOS'; | ||
id = release ? macosRelease(release).name : ''; | ||
return prefix + (id ? ' ' + id : ''); | ||
@@ -24,3 +27,7 @@ } | ||
if (platform === 'linux') { | ||
id = release.replace(/^(\d+\.\d+).*/, '$1'); | ||
if (!release && os.platform() === 'linux') { | ||
release = os.release(); | ||
} | ||
id = release ? release.replace(/^(\d+\.\d+).*/, '$1') : ''; | ||
return 'Linux' + (id ? ' ' + id : ''); | ||
@@ -30,3 +37,7 @@ } | ||
if (platform === 'win32') { | ||
id = winRelease(release); | ||
if (!release && os.platform() === 'win32') { | ||
release = os.release(); | ||
} | ||
id = release ? winRelease(release) : ''; | ||
return 'Windows' + (id ? ' ' + id : ''); | ||
@@ -33,0 +44,0 @@ } |
{ | ||
"name": "os-name", | ||
"version": "2.0.1", | ||
"description": "Get the name of the current operating system. Example: macOS Sierra", | ||
"license": "MIT", | ||
"repository": "sindresorhus/os-name", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
}, | ||
"engines": { | ||
"node": ">=0.10.0" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava" | ||
}, | ||
"files": [ | ||
"index.js" | ||
], | ||
"keywords": [ | ||
"os", | ||
"operating", | ||
"system", | ||
"platform", | ||
"name", | ||
"title", | ||
"release", | ||
"version", | ||
"macos", | ||
"osx", | ||
"windows", | ||
"linux" | ||
], | ||
"dependencies": { | ||
"macos-release": "^1.0.0", | ||
"win-release": "^1.0.0" | ||
}, | ||
"devDependencies": { | ||
"ava": "*", | ||
"xo": "*" | ||
} | ||
"name": "os-name", | ||
"version": "3.0.0", | ||
"description": "Get the name of the current operating system. Example: macOS Sierra", | ||
"license": "MIT", | ||
"repository": "sindresorhus/os-name", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
}, | ||
"engines": { | ||
"node": ">=6" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava" | ||
}, | ||
"files": [ | ||
"index.js" | ||
], | ||
"keywords": [ | ||
"os", | ||
"operating", | ||
"system", | ||
"platform", | ||
"name", | ||
"title", | ||
"release", | ||
"version", | ||
"macos", | ||
"windows", | ||
"linux" | ||
], | ||
"dependencies": { | ||
"macos-release": "^2.0.0", | ||
"windows-release": "^3.1.0" | ||
}, | ||
"devDependencies": { | ||
"ava": "^0.25.0", | ||
"xo": "^0.23.0" | ||
} | ||
} |
@@ -12,3 +12,3 @@ # os-name [![Build Status](https://travis-ci.org/sindresorhus/os-name.svg?branch=master)](https://travis-ci.org/sindresorhus/os-name) | ||
``` | ||
$ npm install --save os-name | ||
$ npm install os-name | ||
``` | ||
@@ -23,3 +23,3 @@ | ||
// on a macOS Sierra system | ||
// On a macOS Sierra system | ||
@@ -47,7 +47,7 @@ osName(); | ||
By default the name of the current operating system is returned. | ||
By default, the name of the current operating system is returned. | ||
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). | ||
You 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). | ||
Check out [getos](https://github.com/wblankenship/getos) if you need the Linux distribution name. | ||
Check out [`getos`](https://github.com/wblankenship/getos) if you need the Linux distribution name. | ||
@@ -54,0 +54,0 @@ |
Sorry, the diff of this file is not supported yet
4274
34
+ Addedwindows-release@^3.1.0
+ Addedcross-spawn@6.0.5(transitive)
+ Addedend-of-stream@1.4.4(transitive)
+ Addedexeca@1.0.0(transitive)
+ Addedget-stream@4.1.0(transitive)
+ Addedis-stream@1.1.0(transitive)
+ Addedisexe@2.0.0(transitive)
+ Addedmacos-release@2.5.1(transitive)
+ Addednice-try@1.0.5(transitive)
+ Addednpm-run-path@2.0.2(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedp-finally@1.0.0(transitive)
+ Addedpath-key@2.0.1(transitive)
+ Addedpump@3.0.0(transitive)
+ Addedshebang-command@1.2.0(transitive)
+ Addedshebang-regex@1.0.0(transitive)
+ Addedsignal-exit@3.0.7(transitive)
+ Addedstrip-eof@1.0.0(transitive)
+ Addedwhich@1.3.1(transitive)
+ Addedwindows-release@3.3.3(transitive)
+ Addedwrappy@1.0.2(transitive)
- Removedwin-release@^1.0.0
- Removedmacos-release@1.1.0(transitive)
- Removedwin-release@1.1.1(transitive)
Updatedmacos-release@^2.0.0