node 4 compatibility fix
This commit is contained in:
parent
ede3890382
commit
1fa813fe38
@ -13,13 +13,12 @@
|
|||||||
// 3. Operating System
|
// 3. Operating System
|
||||||
// ----------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------
|
||||||
|
|
||||||
const nodeUtil = require('util');
|
const os = require('os');
|
||||||
|
const fs = require('fs');
|
||||||
|
const util = require('./util');
|
||||||
const exec = require('child_process').exec;
|
const exec = require('child_process').exec;
|
||||||
const execSync = require('child_process').execSync;
|
const execSync = require('child_process').execSync;
|
||||||
const execPromise = nodeUtil.promisify(require('child_process').exec);
|
const execPromise = util.promisify(require('child_process').exec);
|
||||||
const os = require('os');
|
|
||||||
const util = require('./util');
|
|
||||||
const fs = require('fs');
|
|
||||||
|
|
||||||
let _platform = process.platform;
|
let _platform = process.platform;
|
||||||
|
|
||||||
@ -334,7 +333,7 @@ function osInfo(callback) {
|
|||||||
result.build = util.getValue(lines, 'BuildNumber', '=').trim();
|
result.build = util.getValue(lines, 'BuildNumber', '=').trim();
|
||||||
result.servicepack = util.getValue(lines, 'ServicePackMajorVersion', '=').trim() + '.' + util.getValue(lines, 'ServicePackMinorVersion', '=').trim();
|
result.servicepack = util.getValue(lines, 'ServicePackMajorVersion', '=').trim() + '.' + util.getValue(lines, 'ServicePackMinorVersion', '=').trim();
|
||||||
result.codepage = util.getCodepage();
|
result.codepage = util.getCodepage();
|
||||||
const systeminfo = data.results[1] ? data.results[1].stdout.toString() : '';
|
const systeminfo = data.results[1] ? data.results[1].toString() : '';
|
||||||
result.hypervisor = (systeminfo.indexOf('hypervisor has been detected') !== -1) || (systeminfo.indexOf('Es wurde ein Hypervisor erkannt') !== -1) || (systeminfo.indexOf('Un hyperviseur a ') !== -1);
|
result.hypervisor = (systeminfo.indexOf('hypervisor has been detected') !== -1) || (systeminfo.indexOf('Es wurde ein Hypervisor erkannt') !== -1) || (systeminfo.indexOf('Un hyperviseur a ') !== -1);
|
||||||
isUefiWindows().then(uefi => {
|
isUefiWindows().then(uefi => {
|
||||||
result.uefi = uefi;
|
result.uefi = uefi;
|
||||||
|
|||||||
@ -13,13 +13,12 @@
|
|||||||
// 2. System (Hardware, BIOS, Base Board)
|
// 2. System (Hardware, BIOS, Base Board)
|
||||||
// ----------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------
|
||||||
|
|
||||||
const nodeUtil = require('util');
|
|
||||||
const exec = require('child_process').exec;
|
|
||||||
const execSync = require('child_process').execSync;
|
|
||||||
const execPromise = nodeUtil.promisify(require('child_process').exec);
|
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const os = require('os');
|
const os = require('os');
|
||||||
const util = require('./util');
|
const util = require('./util');
|
||||||
|
const exec = require('child_process').exec;
|
||||||
|
const execSync = require('child_process').execSync;
|
||||||
|
const execPromise = util.promisify(require('child_process').exec);
|
||||||
|
|
||||||
let _platform = process.platform;
|
let _platform = process.platform;
|
||||||
|
|
||||||
@ -585,7 +584,7 @@ function baseboard(callback) {
|
|||||||
util.promiseAll(
|
util.promiseAll(
|
||||||
workload
|
workload
|
||||||
).then(data => {
|
).then(data => {
|
||||||
let lines = data.results[0] ? data.results[0].stdout.toString().split('\n') : [''];
|
let lines = data.results[0] ? data.results[0].toString().split('\n') : [''];
|
||||||
result.manufacturer = util.getValue(lines, 'Manufacturer');
|
result.manufacturer = util.getValue(lines, 'Manufacturer');
|
||||||
result.model = util.getValue(lines, 'Product Name');
|
result.model = util.getValue(lines, 'Product Name');
|
||||||
result.version = util.getValue(lines, 'Version');
|
result.version = util.getValue(lines, 'Version');
|
||||||
@ -611,7 +610,7 @@ function baseboard(callback) {
|
|||||||
if (result.assetTag.toLowerCase().indexOf('o.e.m.') !== -1) { result.assetTag = '-'; }
|
if (result.assetTag.toLowerCase().indexOf('o.e.m.') !== -1) { result.assetTag = '-'; }
|
||||||
|
|
||||||
// mem
|
// mem
|
||||||
lines = data.results[1] ? data.results[1].stdout.toString().split('\n') : [''];
|
lines = data.results[1] ? data.results[1].toString().split('\n') : [''];
|
||||||
result.memMax = util.toInt(util.getValue(lines, 'Maximum Capacity')) * 1024 * 1024 * 1024 || null;
|
result.memMax = util.toInt(util.getValue(lines, 'Maximum Capacity')) * 1024 * 1024 * 1024 || null;
|
||||||
result.memSlots = util.toInt(util.getValue(lines, 'Number Of Devices')) || null;
|
result.memSlots = util.toInt(util.getValue(lines, 'Number Of Devices')) || null;
|
||||||
|
|
||||||
@ -639,7 +638,7 @@ function baseboard(callback) {
|
|||||||
util.promiseAll(
|
util.promiseAll(
|
||||||
workload
|
workload
|
||||||
).then(data => {
|
).then(data => {
|
||||||
let lines = data.results[0] ? data.results[0].stdout.toString().replace(/[<>"]/g, '').split('\n') : [''];
|
let lines = data.results[0] ? data.results[0].toString().replace(/[<>"]/g, '').split('\n') : [''];
|
||||||
result.manufacturer = util.getValue(lines, 'manufacturer', '=', true);
|
result.manufacturer = util.getValue(lines, 'manufacturer', '=', true);
|
||||||
result.model = util.getValue(lines, 'model', '=', true);
|
result.model = util.getValue(lines, 'model', '=', true);
|
||||||
result.version = util.getValue(lines, 'version', '=', true);
|
result.version = util.getValue(lines, 'version', '=', true);
|
||||||
@ -647,9 +646,9 @@ function baseboard(callback) {
|
|||||||
result.assetTag = util.getValue(lines, 'board-id', '=', true);
|
result.assetTag = util.getValue(lines, 'board-id', '=', true);
|
||||||
|
|
||||||
// mem
|
// mem
|
||||||
let devices = data.results[1] ? data.results[1].stdout.toString().split(' BANK ') : [''];
|
let devices = data.results[1] ? data.results[1].toString().split(' BANK ') : [''];
|
||||||
if (devices.length === 1) {
|
if (devices.length === 1) {
|
||||||
devices = data.results[1] ? data.results[1].stdout.toString().split(' DIMM') : [''];
|
devices = data.results[1] ? data.results[1].toString().split(' DIMM') : [''];
|
||||||
}
|
}
|
||||||
devices.shift();
|
devices.shift();
|
||||||
result.memSlots = devices.length;
|
result.memSlots = devices.length;
|
||||||
|
|||||||
30
lib/util.js
30
lib/util.js
@ -871,6 +871,34 @@ function promiseAll(promises) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function promisify(nodeStyleFunction) {
|
||||||
|
return function () {
|
||||||
|
var args = Array.prototype.slice.call(arguments);
|
||||||
|
return new Promise(function (resolve, reject) {
|
||||||
|
args.push(function (err, data) {
|
||||||
|
if (err) {
|
||||||
|
reject(err);
|
||||||
|
} else {
|
||||||
|
resolve(data);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
nodeStyleFunction.apply(null, args);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function linuxVersion() {
|
||||||
|
let result = '';
|
||||||
|
if (_linux) {
|
||||||
|
try {
|
||||||
|
result = execSync('uname -v').toString();
|
||||||
|
} catch (e) {
|
||||||
|
result = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
function noop() { }
|
function noop() { }
|
||||||
|
|
||||||
exports.toInt = toInt;
|
exports.toInt = toInt;
|
||||||
@ -901,6 +929,8 @@ exports.sanitizeShellString = sanitizeShellString;
|
|||||||
exports.isPrototypePolluted = isPrototypePolluted;
|
exports.isPrototypePolluted = isPrototypePolluted;
|
||||||
exports.decodePiCpuinfo = decodePiCpuinfo;
|
exports.decodePiCpuinfo = decodePiCpuinfo;
|
||||||
exports.promiseAll = promiseAll;
|
exports.promiseAll = promiseAll;
|
||||||
|
exports.promisify = promisify;
|
||||||
|
exports.linuxVersion = linuxVersion;
|
||||||
exports.stringReplace = stringReplace;
|
exports.stringReplace = stringReplace;
|
||||||
exports.stringToLower = stringToLower;
|
exports.stringToLower = stringToLower;
|
||||||
exports.stringToString = stringToString;
|
exports.stringToString = stringToString;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user