UNPKG

807 BJavaScriptView Raw
1'use strict';
2var os = require('os');
3
4var win32 = {
5 '6.3': '8.1',
6 '6.2': '8',
7 '6.1': '7',
8 '6.0': 'Vista',
9 '5.1': 'XP',
10 '5.0': '2000',
11 '4.9': 'ME',
12 '4.1': '98',
13 '4.0': '95'
14};
15
16module.exports = function (platform, release) {
17 if (!platform && release) {
18 throw new Error('You can\'t specify a `release` without specfying `platform`');
19 }
20
21 platform = platform || os.platform();
22 release = release || os.release();
23
24 var id;
25
26 if (platform === 'darwin') {
27 id = require('osx-release')(release).name;
28 return 'OS X' + (id ? ' ' + id : '');
29 }
30
31 if (platform === 'linux') {
32 id = release.replace(/^(\d+\.\d+).*/, '$1');
33 return 'Linux' + (id ? ' ' + id : '');
34 }
35
36 if (platform === 'win32') {
37 id = win32[release.slice(0, 3)];
38 return 'Windows' + (id ? ' ' + id : '');
39 }
40
41 return platform;
42};