Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require Node.js 6 and upgrade dependencies #5

Merged
merged 2 commits into from
Nov 20, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
sudo: false
language: node_js
node_js:
- '10'
- '8'
- '6'
- '4'
- '0.12'
- '0.10'
15 changes: 8 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,32 @@
'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) {
if (!platform && release) {
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';
release = release || os.release();
const prefix = Number(release.split('.')[0]) > 15 ? 'macOS' : 'OS X';
id = macosRelease(release).name;
return prefix + (id ? ' ' + id : '');
}

if (platform === 'linux') {
release = release || os.release();
id = release.replace(/^(\d+\.\d+).*/, '$1');
return 'Linux' + (id ? ' ' + id : '');
}

if (platform === 'win32') {
id = winRelease(release);
id = release ? winRelease(release) : '';
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should still return Windows 10 if calling osName() or osName('win32') (notice no arguments) on Windows 10.

Copy link
Contributor Author

@jacargentina jacargentina Oct 28, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So fuzzy... So you want:

When running in the same os than the queried, return full OS + release name

Otherwise, return the OS only

Right?

return 'Windows' + (id ? ' ' + id : '');
}

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
"linux"
],
"dependencies": {
"macos-release": "^1.0.0",
"win-release": "^1.0.0"
"macos-release": "^2.0.0",
"windows-release": "^3.1.0"
},
"devDependencies": {
"ava": "*",
Expand Down
7 changes: 6 additions & 1 deletion test.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import test from 'ava';
import m from './';
import m from '.';

test(t => {
t.true(m().length > 0);
t.is(m('darwin', '18.0.0'), 'macOS Mojave');
t.is(m('darwin', '17.0.0'), 'macOS High Sierra');
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', '4.90'), 'Windows ME');
t.is(m('win32', '6.2'), 'Windows 8');
t.is(m('win32', '10.0'), 'Windows 10');
t.is(m('win32'), 'Windows');
});