versions() bugfix, optimization postgres

This commit is contained in:
Sebastian Hildebrandt 2018-12-05 23:11:15 +01:00
parent a30a80e4ae
commit e1153faab8
2 changed files with 53 additions and 41 deletions

View File

@ -100,6 +100,7 @@ Other changes
| Version | Date | Comment |
| -------------- | -------------- | -------- |
| 3.51.4 | 2018-12-05 | `versions()` bugfix, optimization postgres |
| 3.51.3 | 2018-11-27 | `mem()` refactoring parsing linux, code cleanup |
| 3.51.2 | 2018-11-26 | `mem()` bugfix parsing `free` output linux |
| 3.51.1 | 2018-11-26 | `processLoad()` bugfix windows |

View File

@ -303,7 +303,7 @@ function versions(callback) {
};
let functionProcessed = (function () {
let totalFunctions = 17;
let totalFunctions = 16;
return function () {
if (--totalFunctions === 0) {
if (callback) {
@ -347,22 +347,22 @@ function versions(callback) {
});
exec('gulp --version', function (error, stdout) {
if (!error) {
result.gulp = stdout.toString().split('\n')[0] || '';
result.gulp = (result.gulp.toLowerCase().split('version')[1] || '').trim();
const gulp = stdout.toString().split('\n')[0] || '';
result.gulp = (gulp.toLowerCase().split('version')[1] || '').trim();
}
functionProcessed();
});
exec('tsc --version', function (error, stdout) {
if (!error) {
result.tsc = stdout.toString().split('\n')[0] || '';
result.tsc = (result.tsc.toLowerCase().split('version')[1] || '').trim();
const tsc = stdout.toString().split('\n')[0] || '';
result.tsc = (tsc.toLowerCase().split('version')[1] || '').trim();
}
functionProcessed();
});
exec('grunt --version', function (error, stdout) {
if (!error) {
result.grunt = stdout.toString().split('\n')[0] || '';
result.grunt = (result.grunt.toLowerCase().split('cli v')[1] || '').trim();
const grunt = stdout.toString().split('\n')[0] || '';
result.grunt = (grunt.toLowerCase().split('cli v')[1] || '').trim();
}
functionProcessed();
});
@ -372,9 +372,9 @@ function versions(callback) {
if (!err) {
exec('git --version', function (error, stdout) {
if (!error) {
result.git = stdout.toString().split('\n')[0] || '';
result.git = (result.git.toLowerCase().split('version')[1] || '').trim();
result.git = (result.git.split(' ')[0] || '').trim();
let git = stdout.toString().split('\n')[0] || '';
git = (git.toLowerCase().split('version')[1] || '').trim();
result.git = (git.split(' ')[0] || '').trim();
}
functionProcessed();
});
@ -383,41 +383,33 @@ function versions(callback) {
} else {
exec('git --version', function (error, stdout) {
if (!error) {
result.git = stdout.toString().split('\n')[0] || '';
result.git = (result.git.toLowerCase().split('version')[1] || '').trim();
result.git = (result.git.split(' ')[0] || '').trim();
let git = stdout.toString().split('\n')[0] || '';
git = (git.toLowerCase().split('version')[1] || '').trim();
result.git = (git.split(' ')[0] || '').trim();
}
functionProcessed();
});
}
exec('git --version', function (error, stdout) {
if (!error) {
result.git = stdout.toString().split('\n')[0] || '';
result.git = (result.git.toLowerCase().split('version')[1] || '').trim();
result.git = (result.git.split(' ')[0] || '').trim();
}
functionProcessed();
});
exec('nginx -v', function (error, stdout) {
if (!error) {
result.nginx = stdout.toString().split('\n')[0] || '';
result.nginx = (result.nginx.toLowerCase().split('/')[1] || '').trim();
const nginx = stdout.toString().split('\n')[0] || '';
result.nginx = (nginx.toLowerCase().split('/')[1] || '').trim();
}
functionProcessed();
});
exec('mysql -V', function (error, stdout) {
if (!error) {
result.mysql = stdout.toString().split('\n')[0] || '';
result.mysql = (result.mysql.toLowerCase().split(',')[0] || '').trim();
const parts = result.mysql.split(' ');
let mysql = stdout.toString().split('\n')[0] || '';
mysql = (mysql.toLowerCase().split(',')[0] || '').trim();
const parts = mysql.split(' ');
result.mysql = (parts[parts.length - 1] || '').trim();
}
functionProcessed();
});
exec('php -v', function (error, stdout) {
if (!error) {
result.php = stdout.toString().split('\n')[0] || '';
let parts = result.php.split('(');
const php = stdout.toString().split('\n')[0] || '';
let parts = php.split('(');
if (parts[0].indexOf('-')) {
parts = parts[0].split('-');
}
@ -427,8 +419,8 @@ function versions(callback) {
});
exec('redis-server --version', function (error, stdout) {
if (!error) {
result.redis = stdout.toString().split('\n')[0] || '';
const parts = result.redis.split(' ');
const redis = stdout.toString().split('\n')[0] || '';
const parts = redis.split(' ');
result.redis = util.getValue(parts, 'v', '=', true);
}
functionProcessed();
@ -450,19 +442,39 @@ function versions(callback) {
});
exec('mongod --version', function (error, stdout) {
if (!error) {
result.mongodb = stdout.toString().split('\n')[0] || '';
result.mongodb = (result.mongodb.toLowerCase().split(',')[0] || '').replace(/[^0-9.]/g, '');
}
functionProcessed();
});
exec('postgres -V', function (error, stdout) {
if (!error) {
const postgresql = stdout.toString().split('\n')[0].split(' ') || [];
result.postgresql = postgresql.length ? postgresql[postgresql.length - 1] : '';
result.mongodb = (result.mongodb.toLowerCase().split(',')[0] || '').replace(/[^0-9.]/g, '');
const mongodb = stdout.toString().split('\n')[0] || '';
result.mongodb = (mongodb.toLowerCase().split(',')[0] || '').replace(/[^0-9.]/g, '');
}
functionProcessed();
});
if (_linux) {
exec('locate bin/postgres', function (error, stdout) {
if (!error) {
const postgresqlBin = stdout.toString().split('\n').sort();
if (postgresqlBin.length) {
exec(postgresqlBin[postgresqlBin.length - 1] + ' -V', function (error, stdout) {
if (!error) {
const postgresql = stdout.toString().split('\n')[0].split(' ') || [];
result.postgresql = postgresql.length ? postgresql[postgresql.length - 1] : '';
}
functionProcessed();
});
} else {
functionProcessed();
}
} else {
functionProcessed();
}
});
} else {
exec('postgres -V', function (error, stdout) {
if (!error) {
const postgresql = stdout.toString().split('\n')[0].split(' ') || [];
result.postgresql = postgresql.length ? postgresql[postgresql.length - 1] : '';
}
functionProcessed();
});
}
} catch (e) {
if (callback) { callback(result); }
resolve(result);
@ -471,7 +483,6 @@ function versions(callback) {
});
}
exports.versions = versions;
function shell(callback) {