()
| 3744 | } |
| 3745 | exports._findMatch = _findMatch; |
| 3746 | function _getOsVersion() { |
| 3747 | // TODO: add windows and other linux, arm variants |
| 3748 | // right now filtering on version is only an ubuntu and macos scenario for tools we build for hosted (python) |
| 3749 | const plat = os.platform(); |
| 3750 | let version = ''; |
| 3751 | if (plat === 'darwin') { |
| 3752 | version = cp.execSync('sw_vers -productVersion').toString(); |
| 3753 | } |
| 3754 | else if (plat === 'linux') { |
| 3755 | // lsb_release process not in some containers, readfile |
| 3756 | // Run cat /etc/lsb-release |
| 3757 | // DISTRIB_ID=Ubuntu |
| 3758 | // DISTRIB_RELEASE=18.04 |
| 3759 | // DISTRIB_CODENAME=bionic |
| 3760 | // DISTRIB_DESCRIPTION="Ubuntu 18.04.4 LTS" |
| 3761 | const lsbContents = module.exports._readLinuxVersionFile(); |
| 3762 | if (lsbContents) { |
| 3763 | const lines = lsbContents.split('\n'); |
| 3764 | for (const line of lines) { |
| 3765 | const parts = line.split('='); |
| 3766 | if (parts.length === 2 && |
| 3767 | (parts[0].trim() === 'VERSION_ID' || |
| 3768 | parts[0].trim() === 'DISTRIB_RELEASE')) { |
| 3769 | version = parts[1] |
| 3770 | .trim() |
| 3771 | .replace(/^"/, '') |
| 3772 | .replace(/"$/, ''); |
| 3773 | break; |
| 3774 | } |
| 3775 | } |
| 3776 | } |
| 3777 | } |
| 3778 | return version; |
| 3779 | } |
| 3780 | exports._getOsVersion = _getOsVersion; |
| 3781 | function _readLinuxVersionFile() { |
| 3782 | const lsbReleaseFile = '/etc/lsb-release'; |
nothing calls this directly
no test coverage detected
searching dependent graphs…