versions() added param to specify which program/lib versions to detect

This commit is contained in:
Sebastian Hildebrandt 2020-03-08 19:22:23 +01:00
parent 8f5babb29c
commit add6dd4d2a
6 changed files with 428 additions and 309 deletions

View File

@ -30,6 +30,7 @@ For major (breaking) changes - version 3 and 2 see end of page.
| Version | Date | Comment | | Version | Date | Comment |
| -------------- | -------------- | -------- | | -------------- | -------------- | -------- |
| 4.23.0 | 2020-03-08 | `versions()` added param to specify which program/lib versions to detect |
| 4.22.7 | 2020-03-08 | `diskLayout()` fixed linux | | 4.22.7 | 2020-03-08 | `diskLayout()` fixed linux |
| 4.22.6 | 2020-03-08 | `network()` fixed DHCP linux| | 4.22.6 | 2020-03-08 | `network()` fixed DHCP linux|
| 4.22.5 | 2020-03-04 | `graphics()` fixed vram macOS | | 4.22.5 | 2020-03-04 | `graphics()` fixed vram macOS |

View File

@ -85,13 +85,13 @@ si.cpu()
(last 7 major and minor version releases) (last 7 major and minor version releases)
- Version 4.23.0: `versions()` added param to specify which program/lib versions to detect
- Version 4.22.0: `services()` added pids (windows) - Version 4.22.0: `services()` added pids (windows)
- Version 4.21.0: added npx copmpatibility - Version 4.21.0: added npx copmpatibility
- Version 4.20.0: `battery()` added designcapacity, voltage, unit - Version 4.20.0: `battery()` added designcapacity, voltage, unit
- Version 4.19.0: `osInfo()` added uefi (OS uses UEFI during startup) - Version 4.19.0: `osInfo()` added uefi (OS uses UEFI during startup)
- Version 4.18.0: `networkInterfaces()` added dhcp for mac os, added dhcp linux fallback - Version 4.18.0: `networkInterfaces()` added dhcp for mac os, added dhcp linux fallback
- Version 4.17.0: `networkInterfaces()` added dhcp, dnsSuffix, ieee8021xAuth, ieee8021xState - Version 4.17.0: `networkInterfaces()` added dhcp, dnsSuffix, ieee8021xAuth, ieee8021xState
- Version 4.16.0: `networkGatewayDefault()` added
- ... - ...
You can find all changes here: [detailed changelog][changelog-url] You can find all changes here: [detailed changelog][changelog-url]
@ -296,7 +296,7 @@ I also created a nice little command line tool called [mmon][mmon-github-url] (
| | uefi | X | X | X | X | | OS started via UEFI | | | uefi | X | X | X | X | | OS started via UEFI |
| si.uuid(cb) | {...} | X | X | X | X | X | object of several UUIDs | | si.uuid(cb) | {...} | X | X | X | X | X | object of several UUIDs |
| | os | X | X | X | X | | os specific UUID | | | os | X | X | X | X | | os specific UUID |
| si.versions(cb) | {...} | X | X | X | X | X | version information (kernel, ssl, node, ...) | | si.versions(apps, cb) | {...} | X | X | X | X | X | version information (kernel, ssl, node, ...)<br />apps param is optional for detecting<br />only specific apps/libs<br />(string, comma separated) |
| si.shell(cb) | : string | X | X | X | | | standard shell | | si.shell(cb) | : string | X | X | X | | | standard shell |
| si.users(cb) | [{...}] | X | X | X | X | X | array of users online | | si.users(cb) | [{...}] | X | X | X | X | X | array of users online |
| | [0].user | X | X | X | X | X | user name | | | [0].user | X | X | X | X | X | user name |

View File

@ -83,6 +83,11 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr>
<th scope="row">4.23.0</th>
<td>2020-03-08</td>
<td><span class="code">versions()</span> added param to specify which program/lib versions to detect</td>
</tr>
<tr> <tr>
<th scope="row">4.22.7</th> <th scope="row">4.22.7</th>
<td>2020-03-08</td> <td>2020-03-08</td>

View File

@ -168,7 +168,7 @@
<img class="logo" src="assets/logo.png"> <img class="logo" src="assets/logo.png">
<div class="title">systeminformation</div> <div class="title">systeminformation</div>
<div class="subtitle"><span id="typed"></span></div> <div class="subtitle"><span id="typed"></span></div>
<div class="version">Current Version: <span id="version">4.22.7</span></div> <div class="version">Current Version: <span id="version">4.23.0</span></div>
<button class="btn btn-light" onclick="location.href='https://github.com/sebhildebrandt/systeminformation'">View on Github <i class=" fab fa-github"></i></button> <button class="btn btn-light" onclick="location.href='https://github.com/sebhildebrandt/systeminformation'">View on Github <i class=" fab fa-github"></i></button>
</div> </div>
<div class="down"> <div class="down">

View File

@ -259,14 +259,14 @@ si.osInfo().then(data => console.log(data));</code></pre class="example">
<td>standard shell</td> <td>standard shell</td>
</tr> </tr>
<tr> <tr>
<td>si.versions(cb)</td> <td>si.versions(apps, cb)</td>
<td>{...}</td> <td>{...}</td>
<td>X</td> <td>X</td>
<td>X</td> <td>X</td>
<td>X</td> <td>X</td>
<td>X</td> <td>X</td>
<td>X</td> <td>X</td>
<td>version information of<br>node and dev software packages</td> <td>version information of<br>node and dev software packages<br>optional apps param (string, <br>comma or space seperated)<br>only those apps are detected</td>
</tr> </tr>
<tr> <tr>
<td></td> <td></td>
@ -586,6 +586,15 @@ si.versions().then(data => console.log(data));</code></pre class="example">
java: '', java: '',
gcc: '4.2.1', gcc: '4.2.1',
virtualbox: '' virtualbox: ''
}</pre>
<h5>Example 2</h5>
<pre><code class="js">const si = require('systeminformation');
si.versions('npm, php, postgresql').then(data => console.log(data));</code></pre class="example">
<pre class="example">
{
npm: '6.13.6',
php: '7.3.11',
postgresql: '12.1'
}</pre> }</pre>
</tr> </tr>
<tr> <tr>

View File

@ -351,12 +351,10 @@ function isUefiWindows() {
}); });
} }
function versions(callback) { function versions(apps, callback) {
return new Promise((resolve) => { let versionObject = {
process.nextTick(() => {
let result = {
kernel: os.release(), kernel: os.release(),
openssl: process.versions.openssl, openssl: '',
systemOpenssl: '', systemOpenssl: '',
systemOpensslLib: '', systemOpensslLib: '',
node: process.versions.node, node: process.versions.node,
@ -388,70 +386,131 @@ function versions(callback) {
dotnet: '' dotnet: ''
}; };
function checkVersionParam(apps) {
if (apps === '*') {
return {
versions: versionObject,
counter: 26
}
}
if (!Array.isArray(apps)) {
apps = apps.trim().toLowerCase().replace(/,+/g, '|').replace(/ /g, '|');
apps = apps.split('|');
const result = {
versions: {},
counter: 0
}
apps.forEach(el => {
if (el) {
for (let key in versionObject) {
if ({}.hasOwnProperty.call(versionObject, key)) {
if (key.toLowerCase() === el.toLowerCase() && !{}.hasOwnProperty.call(result.versions, key)) {
result.versions[key] = versionObject[key];
if (key === 'openssl') {
result.versions.systemOpenssl = '';
result.versions.systemOpensslLib = '';
}
if (!result.versions[key]) { result.counter++; }
}
}
}
}
});
return result;
}
}
return new Promise((resolve) => {
process.nextTick(() => {
if (util.isFunction(apps) && !callback) {
callback = apps;
apps = '*';
} else {
apps = apps || '*';
}
const appsObj = checkVersionParam(apps);
let totalFunctions = appsObj.counter;
let functionProcessed = (function () { let functionProcessed = (function () {
let totalFunctions = 26;
return function () { return function () {
if (--totalFunctions === 0) { if (--totalFunctions === 0) {
if (callback) { if (callback) {
callback(result); callback(appsObj.versions);
} }
resolve(result); resolve(appsObj.versions);
} }
}; };
})(); })();
try { try {
if ({}.hasOwnProperty.call(appsObj.versions, 'openssl')) {
appsObj.versions.openssl = process.versions.openssl;
exec('openssl version', function (error, stdout) { exec('openssl version', function (error, stdout) {
if (!error) { if (!error) {
let openssl_string = stdout.toString().split('\n')[0].trim(); let openssl_string = stdout.toString().split('\n')[0].trim();
let openssl = openssl_string.split(' '); let openssl = openssl_string.split(' ');
result.systemOpenssl = openssl.length > 0 ? openssl[1] : openssl[0]; appsObj.versions.systemOpenssl = openssl.length > 0 ? openssl[1] : openssl[0];
result.systemOpensslLib = openssl.length > 0 ? openssl[0] : 'openssl'; appsObj.versions.systemOpensslLib = openssl.length > 0 ? openssl[0] : 'openssl';
} }
functionProcessed(); functionProcessed();
}); });
}
if ({}.hasOwnProperty.call(appsObj.versions, 'npm')) {
exec('npm -v', function (error, stdout) { exec('npm -v', function (error, stdout) {
if (!error) { if (!error) {
result.npm = stdout.toString().split('\n')[0]; appsObj.versions.npm = stdout.toString().split('\n')[0];
} }
functionProcessed(); functionProcessed();
}); });
}
if ({}.hasOwnProperty.call(appsObj.versions, 'pm2')) {
exec('pm2 -v', function (error, stdout) { exec('pm2 -v', function (error, stdout) {
if (!error) { if (!error) {
let pm2 = stdout.toString().split('\n')[0].trim(); let pm2 = stdout.toString().split('\n')[0].trim();
if (!pm2.startsWith('[PM2]')) { if (!pm2.startsWith('[PM2]')) {
result.pm2 = pm2; appsObj.versions.pm2 = pm2;
} }
} }
functionProcessed(); functionProcessed();
}); });
}
if ({}.hasOwnProperty.call(appsObj.versions, 'yarn')) {
exec('yarn --version', function (error, stdout) { exec('yarn --version', function (error, stdout) {
if (!error) { if (!error) {
result.yarn = stdout.toString().split('\n')[0]; appsObj.versions.yarn = stdout.toString().split('\n')[0];
} }
functionProcessed(); functionProcessed();
}); });
}
if ({}.hasOwnProperty.call(appsObj.versions, 'gulp')) {
exec('gulp --version', function (error, stdout) { exec('gulp --version', function (error, stdout) {
if (!error) { if (!error) {
const gulp = stdout.toString().split('\n')[0] || ''; const gulp = stdout.toString().split('\n')[0] || '';
result.gulp = (gulp.toLowerCase().split('version')[1] || '').trim(); appsObj.versions.gulp = (gulp.toLowerCase().split('version')[1] || '').trim();
} }
functionProcessed(); functionProcessed();
}); });
}
if ({}.hasOwnProperty.call(appsObj.versions, 'tsc')) {
exec('tsc --version', function (error, stdout) { exec('tsc --version', function (error, stdout) {
if (!error) { if (!error) {
const tsc = stdout.toString().split('\n')[0] || ''; const tsc = stdout.toString().split('\n')[0] || '';
result.tsc = (tsc.toLowerCase().split('version')[1] || '').trim(); appsObj.versions.tsc = (tsc.toLowerCase().split('version')[1] || '').trim();
} }
functionProcessed(); functionProcessed();
}); });
}
if ({}.hasOwnProperty.call(appsObj.versions, 'grunt')) {
exec('grunt --version', function (error, stdout) { exec('grunt --version', function (error, stdout) {
if (!error) { if (!error) {
const grunt = stdout.toString().split('\n')[0] || ''; const grunt = stdout.toString().split('\n')[0] || '';
result.grunt = (grunt.toLowerCase().split('cli v')[1] || '').trim(); appsObj.versions.grunt = (grunt.toLowerCase().split('cli v')[1] || '').trim();
} }
functionProcessed(); functionProcessed();
}); });
}
if ({}.hasOwnProperty.call(appsObj.versions, 'git')) {
if (_darwin) { if (_darwin) {
const gitHomebrewExists = fs.existsSync('/usr/local/Cellar/git'); const gitHomebrewExists = fs.existsSync('/usr/local/Cellar/git');
if (util.darwinXcodeExists() || gitHomebrewExists) { if (util.darwinXcodeExists() || gitHomebrewExists) {
@ -459,7 +518,7 @@ function versions(callback) {
if (!error) { if (!error) {
let git = stdout.toString().split('\n')[0] || ''; let git = stdout.toString().split('\n')[0] || '';
git = (git.toLowerCase().split('version')[1] || '').trim(); git = (git.toLowerCase().split('version')[1] || '').trim();
result.git = (git.split(' ')[0] || '').trim(); appsObj.versions.git = (git.split(' ')[0] || '').trim();
} }
functionProcessed(); functionProcessed();
}); });
@ -471,25 +530,31 @@ function versions(callback) {
if (!error) { if (!error) {
let git = stdout.toString().split('\n')[0] || ''; let git = stdout.toString().split('\n')[0] || '';
git = (git.toLowerCase().split('version')[1] || '').trim(); git = (git.toLowerCase().split('version')[1] || '').trim();
result.git = (git.split(' ')[0] || '').trim(); appsObj.versions.git = (git.split(' ')[0] || '').trim();
} }
functionProcessed(); functionProcessed();
}); });
} }
}
if ({}.hasOwnProperty.call(appsObj.versions, 'apache')) {
exec('apachectl -v 2>&1', function (error, stdout) { exec('apachectl -v 2>&1', function (error, stdout) {
if (!error) { if (!error) {
const apache = (stdout.toString().split('\n')[0] || '').split(':'); const apache = (stdout.toString().split('\n')[0] || '').split(':');
result.apache = (apache.length > 1 ? apache[1].replace('Apache', '').replace('/', '').trim() : ''); appsObj.versions.apache = (apache.length > 1 ? apache[1].replace('Apache', '').replace('/', '').trim() : '');
} }
functionProcessed(); functionProcessed();
}); });
}
if ({}.hasOwnProperty.call(appsObj.versions, 'nginx')) {
exec('nginx -v 2>&1', function (error, stdout) { exec('nginx -v 2>&1', function (error, stdout) {
if (!error) { if (!error) {
const nginx = stdout.toString().split('\n')[0] || ''; const nginx = stdout.toString().split('\n')[0] || '';
result.nginx = (nginx.toLowerCase().split('/')[1] || '').trim(); appsObj.versions.nginx = (nginx.toLowerCase().split('/')[1] || '').trim();
} }
functionProcessed(); functionProcessed();
}); });
}
if ({}.hasOwnProperty.call(appsObj.versions, 'mysql')) {
exec('mysql -V', function (error, stdout) { exec('mysql -V', function (error, stdout) {
if (!error) { if (!error) {
let mysql = stdout.toString().split('\n')[0] || ''; let mysql = stdout.toString().split('\n')[0] || '';
@ -497,16 +562,18 @@ function versions(callback) {
if (mysql.indexOf(',') > -1) { if (mysql.indexOf(',') > -1) {
mysql = (mysql.split(',')[0] || '').trim(); mysql = (mysql.split(',')[0] || '').trim();
const parts = mysql.split(' '); const parts = mysql.split(' ');
result.mysql = (parts[parts.length - 1] || '').trim(); appsObj.versions.mysql = (parts[parts.length - 1] || '').trim();
} else { } else {
if (mysql.indexOf(' ver ') > -1) { if (mysql.indexOf(' ver ') > -1) {
mysql = mysql.split(' ver ')[1]; mysql = mysql.split(' ver ')[1];
result.mysql = mysql.split(' ')[0]; appsObj.versions.mysql = mysql.split(' ')[0];
} }
} }
} }
functionProcessed(); functionProcessed();
}); });
}
if ({}.hasOwnProperty.call(appsObj.versions, 'php')) {
exec('php -v', function (error, stdout) { exec('php -v', function (error, stdout) {
if (!error) { if (!error) {
const php = stdout.toString().split('\n')[0] || ''; const php = stdout.toString().split('\n')[0] || '';
@ -514,40 +581,50 @@ function versions(callback) {
if (parts[0].indexOf('-')) { if (parts[0].indexOf('-')) {
parts = parts[0].split('-'); parts = parts[0].split('-');
} }
result.php = parts[0].replace(/[^0-9.]/g, ''); appsObj.versions.php = parts[0].replace(/[^0-9.]/g, '');
} }
functionProcessed(); functionProcessed();
}); });
}
if ({}.hasOwnProperty.call(appsObj.versions, 'redis')) {
exec('redis-server --version', function (error, stdout) { exec('redis-server --version', function (error, stdout) {
if (!error) { if (!error) {
const redis = stdout.toString().split('\n')[0] || ''; const redis = stdout.toString().split('\n')[0] || '';
const parts = redis.split(' '); const parts = redis.split(' ');
result.redis = util.getValue(parts, 'v', '=', true); appsObj.versions.redis = util.getValue(parts, 'v', '=', true);
} }
functionProcessed(); functionProcessed();
}); });
}
if ({}.hasOwnProperty.call(appsObj.versions, 'docker')) {
exec('docker --version', function (error, stdout) { exec('docker --version', function (error, stdout) {
if (!error) { if (!error) {
const docker = stdout.toString().split('\n')[0] || ''; const docker = stdout.toString().split('\n')[0] || '';
const parts = docker.split(' '); const parts = docker.split(' ');
result.docker = parts.length > 2 && parts[2].endsWith(',') ? parts[2].slice(0, -1) : ''; appsObj.versions.docker = parts.length > 2 && parts[2].endsWith(',') ? parts[2].slice(0, -1) : '';
} }
functionProcessed(); functionProcessed();
}); });
}
if ({}.hasOwnProperty.call(appsObj.versions, 'postfix')) {
exec('postconf -d | grep mail_version', function (error, stdout) { exec('postconf -d | grep mail_version', function (error, stdout) {
if (!error) { if (!error) {
const postfix = stdout.toString().split('\n') || []; const postfix = stdout.toString().split('\n') || [];
result.postfix = util.getValue(postfix, 'mail_version', '=', true); appsObj.versions.postfix = util.getValue(postfix, 'mail_version', '=', true);
} }
functionProcessed(); functionProcessed();
}); });
}
if ({}.hasOwnProperty.call(appsObj.versions, 'mongodb')) {
exec('mongod --version', function (error, stdout) { exec('mongod --version', function (error, stdout) {
if (!error) { if (!error) {
const mongodb = stdout.toString().split('\n')[0] || ''; const mongodb = stdout.toString().split('\n')[0] || '';
result.mongodb = (mongodb.toLowerCase().split(',')[0] || '').replace(/[^0-9.]/g, ''); appsObj.versions.mongodb = (mongodb.toLowerCase().split(',')[0] || '').replace(/[^0-9.]/g, '');
} }
functionProcessed(); functionProcessed();
}); });
}
if ({}.hasOwnProperty.call(appsObj.versions, 'postgresql')) {
if (_linux) { if (_linux) {
exec('locate bin/postgres', function (error, stdout) { exec('locate bin/postgres', function (error, stdout) {
if (!error) { if (!error) {
@ -556,7 +633,7 @@ function versions(callback) {
exec(postgresqlBin[postgresqlBin.length - 1] + ' -V', function (error, stdout) { exec(postgresqlBin[postgresqlBin.length - 1] + ' -V', function (error, stdout) {
if (!error) { if (!error) {
const postgresql = stdout.toString().split('\n')[0].split(' ') || []; const postgresql = stdout.toString().split('\n')[0].split(' ') || [];
result.postgresql = postgresql.length ? postgresql[postgresql.length - 1] : ''; appsObj.versions.postgresql = postgresql.length ? postgresql[postgresql.length - 1] : '';
} }
functionProcessed(); functionProcessed();
}); });
@ -564,6 +641,14 @@ function versions(callback) {
functionProcessed(); functionProcessed();
} }
} else { } else {
exec('psql -V', function (error, stdout) {
if (!error) {
const postgresql = stdout.toString().split('\n')[0].split(' ') || [];
appsObj.versions.postgresql = postgresql.length ? postgresql[postgresql.length - 1] : '';
appsObj.versions.postgresql = appsObj.versions.postgresql.split('-')[0];
}
functionProcessed();
});
functionProcessed(); functionProcessed();
} }
}); });
@ -578,7 +663,7 @@ function versions(callback) {
if (srvCaption.indexOf('postgresql') > -1) { if (srvCaption.indexOf('postgresql') > -1) {
const parts = srvCaption.split(' server '); const parts = srvCaption.split(' server ');
if (parts.length > 1) { if (parts.length > 1) {
result.postgresql = parts[1]; appsObj.versions.postgresql = parts[1];
} }
} }
} }
@ -589,12 +674,14 @@ function versions(callback) {
exec('postgres -V', function (error, stdout) { exec('postgres -V', function (error, stdout) {
if (!error) { if (!error) {
const postgresql = stdout.toString().split('\n')[0].split(' ') || []; const postgresql = stdout.toString().split('\n')[0].split(' ') || [];
result.postgresql = postgresql.length ? postgresql[postgresql.length - 1] : ''; appsObj.versions.postgresql = postgresql.length ? postgresql[postgresql.length - 1] : '';
} }
functionProcessed(); functionProcessed();
}); });
} }
} }
}
if ({}.hasOwnProperty.call(appsObj.versions, 'perl')) {
exec('perl -v', function (error, stdout) { exec('perl -v', function (error, stdout) {
if (!error) { if (!error) {
const perl = stdout.toString().split('\n') || ''; const perl = stdout.toString().split('\n') || '';
@ -602,41 +689,51 @@ function versions(callback) {
perl.shift(); perl.shift();
} }
if (perl.length > 0) { if (perl.length > 0) {
result.perl = perl[0].split('(').pop().split(')')[0].replace('v', ''); appsObj.versions.perl = perl[0].split('(').pop().split(')')[0].replace('v', '');
} }
} }
functionProcessed(); functionProcessed();
}); });
}
if ({}.hasOwnProperty.call(appsObj.versions, 'python')) {
exec('python -V 2>&1', function (error, stdout) { exec('python -V 2>&1', function (error, stdout) {
if (!error) { if (!error) {
const python = stdout.toString().split('\n')[0] || ''; const python = stdout.toString().split('\n')[0] || '';
result.python = python.toLowerCase().replace('python', '').trim(); appsObj.versions.python = python.toLowerCase().replace('python', '').trim();
} }
functionProcessed(); functionProcessed();
}); });
}
if ({}.hasOwnProperty.call(appsObj.versions, 'python3')) {
exec('python3 -V 2>&1', function (error, stdout) { exec('python3 -V 2>&1', function (error, stdout) {
if (!error) { if (!error) {
const python = stdout.toString().split('\n')[0] || ''; const python = stdout.toString().split('\n')[0] || '';
result.python3 = python.toLowerCase().replace('python', '').trim(); appsObj.versions.python3 = python.toLowerCase().replace('python', '').trim();
} }
functionProcessed(); functionProcessed();
}); });
}
if ({}.hasOwnProperty.call(appsObj.versions, 'pip')) {
exec('pip -V 2>&1', function (error, stdout) { exec('pip -V 2>&1', function (error, stdout) {
if (!error) { if (!error) {
const pip = stdout.toString().split('\n')[0] || ''; const pip = stdout.toString().split('\n')[0] || '';
const parts = pip.split(' '); const parts = pip.split(' ');
result.pip = parts.length >= 2 ? parts[1] : ''; appsObj.versions.pip = parts.length >= 2 ? parts[1] : '';
} }
functionProcessed(); functionProcessed();
}); });
}
if ({}.hasOwnProperty.call(appsObj.versions, 'pip3')) {
exec('pip3 -V 2>&1', function (error, stdout) { exec('pip3 -V 2>&1', function (error, stdout) {
if (!error) { if (!error) {
const pip = stdout.toString().split('\n')[0] || ''; const pip = stdout.toString().split('\n')[0] || '';
const parts = pip.split(' '); const parts = pip.split(' ');
result.pip3 = parts.length >= 2 ? parts[1] : ''; appsObj.versions.pip3 = parts.length >= 2 ? parts[1] : '';
} }
functionProcessed(); functionProcessed();
}); });
}
if ({}.hasOwnProperty.call(appsObj.versions, 'java')) {
if (_darwin) { if (_darwin) {
// check if any JVM is installed but avoid dialog box that Java needs to be installed // check if any JVM is installed but avoid dialog box that Java needs to be installed
exec('/usr/libexec/java_home -V 2>&1', function (error, stdout) { exec('/usr/libexec/java_home -V 2>&1', function (error, stdout) {
@ -646,7 +743,7 @@ function versions(callback) {
if (!error) { if (!error) {
const java = stdout.toString().split('\n')[0] || ''; const java = stdout.toString().split('\n')[0] || '';
const parts = java.split('"'); const parts = java.split('"');
result.java = parts.length === 3 ? parts[1].trim() : ''; appsObj.versions.java = parts.length === 3 ? parts[1].trim() : '';
} }
functionProcessed(); functionProcessed();
}); });
@ -659,17 +756,19 @@ function versions(callback) {
if (!error) { if (!error) {
const java = stdout.toString().split('\n')[0] || ''; const java = stdout.toString().split('\n')[0] || '';
const parts = java.split('"'); const parts = java.split('"');
result.java = parts.length === 3 ? parts[1].trim() : ''; appsObj.versions.java = parts.length === 3 ? parts[1].trim() : '';
} }
functionProcessed(); functionProcessed();
}); });
} }
}
if ({}.hasOwnProperty.call(appsObj.versions, 'gcc')) {
if ((_darwin && util.darwinXcodeExists()) || !_darwin) { if ((_darwin && util.darwinXcodeExists()) || !_darwin) {
exec('gcc -dumpversion', function (error, stdout) { exec('gcc -dumpversion', function (error, stdout) {
if (!error) { if (!error) {
result.gcc = stdout.toString().split('\n')[0].trim() || ''; appsObj.versions.gcc = stdout.toString().split('\n')[0].trim() || '';
} }
if (result.gcc.indexOf('.') > -1) { if (appsObj.versions.gcc.indexOf('.') > -1) {
functionProcessed(); functionProcessed();
} else { } else {
exec('gcc --version', function (error, stdout) { exec('gcc --version', function (error, stdout) {
@ -677,7 +776,7 @@ function versions(callback) {
const gcc = stdout.toString().split('\n')[0].trim(); const gcc = stdout.toString().split('\n')[0].trim();
if (gcc.indexOf('gcc') > -1 && gcc.indexOf(')') > -1) { if (gcc.indexOf('gcc') > -1 && gcc.indexOf(')') > -1) {
const parts = gcc.split(')'); const parts = gcc.split(')');
result.gcc = parts[1].trim() || result.gcc; appsObj.versions.gcc = parts[1].trim() || appsObj.versions.gcc;
} }
} }
functionProcessed(); functionProcessed();
@ -687,21 +786,26 @@ function versions(callback) {
} else { } else {
functionProcessed(); functionProcessed();
} }
}
if ({}.hasOwnProperty.call(appsObj.versions, 'virtualbox')) {
exec(util.getVboxmanage() + ' -v 2>&1', function (error, stdout) { exec(util.getVboxmanage() + ' -v 2>&1', function (error, stdout) {
if (!error) { if (!error) {
const vbox = stdout.toString().split('\n')[0] || ''; const vbox = stdout.toString().split('\n')[0] || '';
const parts = vbox.split('r'); const parts = vbox.split('r');
result.virtualbox = parts[0]; appsObj.versions.virtualbox = parts[0];
} }
functionProcessed(); functionProcessed();
}); });
}
if ({}.hasOwnProperty.call(appsObj.versions, 'dotnet')) {
exec('dotnet --version 2>&1', function (error, stdout) { exec('dotnet --version 2>&1', function (error, stdout) {
if (!error) { if (!error) {
const dotnet = stdout.toString().split('\n')[0] || ''; const dotnet = stdout.toString().split('\n')[0] || '';
result.dotnet = dotnet.trim(); appsObj.versions.dotnet = dotnet.trim();
} }
functionProcessed(); functionProcessed();
}); });
}
} catch (e) { } catch (e) {
if (callback) { callback(result); } if (callback) { callback(result); }
resolve(result); resolve(result);