-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
34 lines (32 loc) · 837 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const os = require('os');
const process = require('process');
/**
* Get macOS version of current system
*
* @param {number} [darwinRelease] darwin version
* @returns {string| undefined} macOS version or undefined if other platform
* @example
* const {macOSVersion} = require('get-osx-version');
*
* console.log('macOS version: ' + macOSVersion());
*/
module.exports.macOSVersion = darwinRelease => {
if (typeof darwinRelease === 'undefined' && process.platform === 'darwin') {
darwinRelease = Number.parseFloat(os.release());
} else if (typeof darwinRelease === 'undefined') {
return;
}
switch (darwinRelease) {
case 1.3:
return '10.0';
case 1.4:
case 5.1:
case 5.2:
case 5.3:
case 5.4:
case 5.5:
return '10.1';
default:
return '10.' + (Number.parseFloat(darwinRelease) - 4).toFixed(1);
}
};