Skip to content

Commit

Permalink
osInfo() improved release parsing (linux)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebhildebrandt committed Jan 21, 2024
1 parent 9ffc74a commit 38ec864
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/osinfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,14 +243,18 @@ function osInfo(callback) {
release[line.split('=')[0].trim().toUpperCase()] = line.split('=')[1].trim();
}
});
result.distro = (release.DISTRIB_ID || release.NAME || 'unknown').replace(/"/g, '');
result.logofile = getLogoFile(result.distro);
let releaseVersion = (release.VERSION || '').replace(/"/g, '');
let codename = (release.DISTRIB_CODENAME || release.VERSION_CODENAME || '').replace(/"/g, '');
const prettyName = (release.PRETTY_NAME || '').replace(/"/g, '');
if (prettyName.indexOf(result.distro + ' ') === 0) {
releaseVersion = prettyName.replace(result.distro + ' ', '').trim();
}
if (releaseVersion.indexOf('(') >= 0) {
codename = releaseVersion.split('(')[1].replace(/[()]/g, '').trim();
releaseVersion = releaseVersion.split('(')[0].trim();
}
result.distro = (release.DISTRIB_ID || release.NAME || 'unknown').replace(/"/g, '');
result.logofile = getLogoFile(result.distro);
result.release = (releaseVersion || release.DISTRIB_RELEASE || release.VERSION_ID || 'unknown').replace(/"/g, '');
result.codename = codename;
result.codepage = util.getCodepage();
Expand Down

0 comments on commit 38ec864

Please sign in to comment.