MCPcopy Create free account
hub / github.com/Azure/powershell / _getOsVersion

Function _getOsVersion

lib/index.js:3746–3779  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3744}
3745exports._findMatch = _findMatch;
3746function _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}
3780exports._getOsVersion = _getOsVersion;
3781function _readLinuxVersionFile() {
3782 const lsbReleaseFile = '/etc/lsb-release';

Callers

nothing calls this directly

Calls 1

toStringMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…