code cleanup

This commit is contained in:
Sebastian Hildebrandt 2021-01-22 16:47:27 +01:00
parent 65d67fe0a6
commit 2b0885220b
8 changed files with 110 additions and 99 deletions

View File

@ -9,5 +9,16 @@
"parserOptions": {
"ecmaVersion": 12
},
"rules": {}
"rules": {
"semi": [
"error",
"always"
],
"eqeqeq": "off",
"curly": "error",
"quotes": [
"error",
"single"
]
}
}

View File

@ -29,7 +29,7 @@ const _netbsd = (_platform === 'netbsd');
const _sunos = (_platform === 'sunos');
function getLinuxAudioPci() {
let cmd = 'lspci -v 2>/dev/null'
let cmd = 'lspci -v 2>/dev/null';
let result = [];
try {
const parts = execSync(cmd).toString().split('\n\n');
@ -38,7 +38,7 @@ function getLinuxAudioPci() {
if (lines && lines.length && lines[0].toLowerCase().indexOf('audio') >= 0) {
const audio = {};
audio.slotId = lines[0].split(' ')[0];
audio.driver = util.getValue(lines, 'Kernel driver in use', ':', true) || util.getValue(lines, 'Kernel modules', ':', true)
audio.driver = util.getValue(lines, 'Kernel driver in use', ':', true) || util.getValue(lines, 'Kernel modules', ':', true);
result.push(audio);
}
}
@ -52,7 +52,7 @@ function parseLinuxAudioPciMM(lines, audioPCI) {
const result = {};
const slotId = util.getValue(lines, 'Slot');
const pciMatch = audioPCI.filter(function (item) { return item.slotId === slotId })
const pciMatch = audioPCI.filter(function (item) { return item.slotId === slotId; });
result.id = slotId;
result.name = util.getValue(lines, 'SDevice');
@ -87,14 +87,14 @@ function parseDarwinAudio(audioObject, id) {
const channelStr = ((audioObject.coreaudio_device_transport || '') + ' ' + (audioObject._name || '')).toLowerCase();
result.id = id;
result.name = audioObject._name
result.name = audioObject._name;
result.manufacturer = audioObject.coreaudio_device_manufacturer;
result.revision = null;
result.driver = null;
result.default = !!(audioObject.coreaudio_default_audio_input_device || '') || !!(audioObject.coreaudio_default_audio_output_device || '');
result.channel = parseDarwinChannel(channelStr);
result.in = !!(audioObject.coreaudio_device_input || '')
result.out = !!(audioObject.coreaudio_device_output || '')
result.in = !!(audioObject.coreaudio_device_input || '');
result.out = !!(audioObject.coreaudio_device_output || '');
result.status = 'online';
return result;
@ -109,12 +109,12 @@ function parseWindowsAudio(lines) {
result.name = util.getValue(lines, 'name', '=');
result.manufacturer = util.getValue(lines, 'manufacturer', '=');
result.revision = null;
result.driver = null
result.default = null
result.in = null
result.out = null
result.interfaceType = null
result.status = status
result.driver = null;
result.default = null;
result.in = null;
result.out = null;
result.interfaceType = null;
result.status = status;
return result;
}
@ -125,7 +125,7 @@ function audio(callback) {
process.nextTick(() => {
let result = [];
if (_linux || _freebsd || _openbsd || _netbsd) {
let cmd = 'lspci -vmm 2>/dev/null'
let cmd = 'lspci -vmm 2>/dev/null';
exec(cmd, function (error, stdout) {
// PCI
if (!error) {
@ -146,7 +146,7 @@ function audio(callback) {
});
}
if (_darwin) {
let cmd = 'system_profiler SPAudioDataType -json'
let cmd = 'system_profiler SPAudioDataType -json';
exec(cmd, function (error, stdout) {
if (!error) {
try {
@ -158,7 +158,7 @@ function audio(callback) {
}
}
} catch (e) {
util.noop()
util.noop();
}
}
if (callback) {
@ -173,7 +173,7 @@ function audio(callback) {
const parts = stdout.toString().split(/\n\s*\n/);
for (let i = 0; i < parts.length; i++) {
if (util.getValue(parts[i].split('\n'), 'name', '=')) {
result.push(parseWindowsAudio(parts[i].split('\n'), i))
result.push(parseWindowsAudio(parts[i].split('\n'), i));
}
}
}

View File

@ -64,7 +64,7 @@ function parseDarwinBluetoothDevices(bluetoothObject, macAddr2) {
result.device = bluetoothObject.device_services || '';
result.name = bluetoothObject.device_name || '';
result.manufacturer = bluetoothObject.device_manufacturer || '';
result.macDevice = (bluetoothObject.device_addr || '').toLowerCase().replace(/-/g, ':');;
result.macDevice = (bluetoothObject.device_addr || '').toLowerCase().replace(/-/g, ':');
result.macHost = macAddr2;
result.batteryPercent = bluetoothObject.device_batteryPercent || null;
result.type = parseBluetoothTyoe(typeStr);
@ -124,7 +124,7 @@ function bluetoothDevices(callback) {
resolve(result);
}
if (_darwin) {
let cmd = 'system_profiler SPBluetoothDataType -json'
let cmd = 'system_profiler SPBluetoothDataType -json';
exec(cmd, function (error, stdout) {
if (!error) {
try {
@ -148,7 +148,7 @@ function bluetoothDevices(callback) {
}
}
} catch (e) {
util.noop()
util.noop();
}
}
if (callback) {
@ -163,7 +163,7 @@ function bluetoothDevices(callback) {
const parts = stdout.toString().split(/\n\s*\n/);
for (let i = 0; i < parts.length; i++) {
if (util.getValue(parts[i].split('\n'), 'PNPClass', '=') === 'Bluetooth') {
result.push(parseWindowsBluetooth(parts[i].split('\n'), i))
result.push(parseWindowsBluetooth(parts[i].split('\n'), i));
}
}
}

View File

@ -382,7 +382,7 @@ function isUefiWindows() {
resolve(line.toLowerCase().indexOf('uefi') >= 0);
}
resolve(false);
})
});
}
resolve(false);
});

View File

@ -532,7 +532,7 @@ function sanitizeShellString(str) {
}
function isPrototypePolluted() {
const s = '1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
const s = '1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
let notPolluted = true;
let st = '';
@ -541,16 +541,16 @@ function isPrototypePolluted() {
st.__proto__.toString = stringToString;
st.__proto__.substr = stringSubstr;
notPolluted = notPolluted || !(s.length === 62)
notPolluted = notPolluted || !(s.length === 62);
const ms = Date.now();
if (typeof ms === 'number' && ms > 1600000000000) {
const l = ms % 100 + 15;
for (let i = 0; i < l; i++) {
const r = Math.random() * 61.99999999 + 1;
const rs = parseInt(Math.floor(r).toString(), 10)
const rs = parseInt(Math.floor(r).toString(), 10);
const rs2 = parseInt(r.toString().split('.')[0], 10);
const q = Math.random() * 61.99999999 + 1;
const qs = parseInt(Math.floor(q).toString(), 10)
const qs = parseInt(Math.floor(q).toString(), 10);
const qs2 = parseInt(q.toString().split('.')[0], 10);
notPolluted = notPolluted && !(r === q);
notPolluted = notPolluted && rs === rs2 && qs === qs2;
@ -578,7 +578,7 @@ function isPrototypePolluted() {
// lower
const stl = st.toLowerCase();
notPolluted = notPolluted && (stl.length === l) && stl[l - 1] && !(stl[l])
notPolluted = notPolluted && (stl.length === l) && stl[l - 1] && !(stl[l]);
for (let i = 0; i < l; i++) {
const s1 = st[i];
s1.__proto__.toLowerCase = stringToLower;
@ -591,7 +591,7 @@ function isPrototypePolluted() {
}
function hex2bin(hex) {
return ("00000000" + (parseInt(hex, 16)).toString(2)).substr(-8);
return ('00000000' + (parseInt(hex, 16)).toString(2)).substr(-8);
}
function getFilesInPath(source) {
@ -605,10 +605,10 @@ function getFilesInPath(source) {
function isFile(source) { return lstatSync(source).isFile(); }
function getDirectories(source) {
return readdirSync(source).map(function (name) { return join(source, name); }).filter(isDirectory)
return readdirSync(source).map(function (name) { return join(source, name); }).filter(isDirectory);
}
function getFiles(source) {
return readdirSync(source).map(function (name) { return join(source, name); }).filter(isFile)
return readdirSync(source).map(function (name) { return join(source, name); }).filter(isFile);
}
function getFilesRecursively(source) {
@ -750,7 +750,7 @@ function decodePiCpuinfo(lines) {
manufacturer: '512MB Embest',
processor: 'BCM2835'
}
}
};
const processorList = [
'BCM2835',
@ -803,7 +803,7 @@ function decodePiCpuinfo(lines) {
processor: oldRevisionCodes[revisionCode].processor,
type: oldRevisionCodes[revisionCode].type,
revision: oldRevisionCodes[revisionCode].revision,
}
};
} else {
// new revision code
@ -824,7 +824,7 @@ function decodePiCpuinfo(lines) {
processor,
type: {}.hasOwnProperty.call(typeList, typeCode) ? typeList[typeCode] : '',
revision: '1.' + revision.substr(7, 1),
}
};
}
return result;
}

View File

@ -1,7 +1,7 @@
{
"name": "systeminformation",
"version": "4.34.9",
"prereleaseversion": "5.0-alpha.0116",
"prereleaseversion": "5.0-alpha.0117",
"description": "Simple system and OS information library",
"license": "MIT",
"author": "Sebastian Hildebrandt <hildebrandt@plus-innovations.com> (https://plus-innovations.com)",

View File

@ -5,66 +5,66 @@ function test(f) {
process.nextTick(() => {
f = f.replace(/'/g, '');
// console.log(f);
if (f === 'a') { si.audio().then(data => { if (data !== null) { resolve({ data, title: 'Audio' }); } else { resolve('not_supported') } }) }
else if (f === 'b') { si.bios().then(data => { if (data !== null) { resolve({ data, title: 'BIOS' }); } else { resolve('not_supported') } }) }
else if (f === 'B') { si.baseboard().then(data => { if (data !== null) { resolve({ data, title: 'Baseboard' }); } else { resolve('not_supported') } }) }
else if (f === 'C') { si.chassis().then(data => { if (data !== null) { resolve({ data, title: 'Chassis' }); } else { resolve('not_supported') } }) }
else if (f === 'c') { si.cpu().then(data => { if (data !== null) { resolve({ data, title: 'CPU' }); } else { resolve('not_supported') } }) }
else if (f === 'd') { si.diskLayout().then(data => { if (data !== null) { resolve({ data, title: 'Disk Layout' }); } else { resolve('not_supported') } }) }
else if (f === 'D') { si.disksIO().then(data => { if (data !== null) { resolve({ data, title: 'Disks IO' }); } else { resolve('not_supported') } }) }
else if (f === 'e') { si.blockDevices().then(data => { if (data !== null) { resolve({ data, title: 'Block Devices' }); } else { resolve('not_supported') } }) }
else if (f === 'E') { si.fsOpenFiles().then(data => { if (data !== null) { resolve({ data, title: 'Open Files' }); } else { resolve('not_supported') } }) }
else if (f === 'f') { si.fsSize().then(data => { if (data !== null) { resolve({ data, title: 'File System' }); } else { resolve('not_supported') } }) }
else if (f === 'F') { si.fsStats().then(data => { if (data !== null) { resolve({ data, title: 'FS Stats' }); } else { resolve('not_supported') } }) }
else if (f === 'g') { si.graphics().then(data => { if (data !== null) { resolve({ data, title: 'Graphics' }); } else { resolve('not_supported') } }) }
else if (f === 'h') { si.bluetoothDevices().then(data => { if (data !== null) { resolve({ data, title: 'Bluetooth' }); } else { resolve('not_supported') } }) }
else if (f === 'i') { si.inetLatency().then(data => { if (data !== null) { resolve({ data, title: 'Internet Latency' }); } else { resolve('not_supported') } }) }
else if (f === 'I') { si.inetChecksite('https://systeminformation.io').then(data => { if (data !== null) { resolve({ data, title: 'Internet Check Site' }); } else { resolve('not_supported') } }) }
else if (f === 'j') { si.cpuCurrentSpeed().then(data => { if (data !== null) { resolve({ data, title: 'CPU Current Speed' }); } else { resolve('not_supported') } }) }
else if (f === 'l') { si.currentLoad().then(data => { if (data !== null) { resolve({ data, title: 'CPU Current Load' }); } else { resolve('not_supported') } }) }
else if (f === 'L') { si.fullLoad().then(data => { if (data !== null) { resolve({ data, title: 'CPU Full Load' }); } else { resolve('not_supported') } }) }
else if (f === 'm') { si.mem().then(data => { if (data !== null) { resolve({ data, title: 'Memory' }); } else { resolve('not_supported') } }) }
else if (f === 'M') { si.memLayout().then(data => { if (data !== null) { resolve({ data, title: 'Memory Layout' }); } else { resolve('not_supported') } }) }
else if (f === 'o') { si.osInfo().then(data => { if (data !== null) { resolve({ data, title: 'OS Info' }); } else { resolve('not_supported') } }) }
else if (f === 'p') { si.processes().then(data => { if (data !== null) { resolve({ data, title: 'Processes' }); } else { resolve('not_supported') } }) }
else if (f === 'P') { si.processLoad('postgres, login, apache, mysql, nginx, git').then(data => { if (data !== null) { resolve({ data, title: 'Process Load' }); } else { resolve('not_supported') } }) }
else if (f === 'r') { si.printer().then(data => { if (data !== null) { resolve({ data, title: 'Printer' }); } else { resolve('not_supported') } }) }
else if (f === 's') { si.services('apache2, postgres').then(data => { if (data !== null) { resolve({ data, title: 'Services' }); } else { resolve('not_supported') } }) }
else if (f === 'S') { si.shell().then(data => { if (data !== null) { resolve({ data, title: 'Shell' }); } else { resolve('not_supported') } }) }
else if (f === 't') { resolve({ data: si.time(), title: 'Time' }) }
else if (f === 'T') { si.cpuTemperature().then(data => { if (data !== null) { resolve({ data, title: 'CPU Temperature' }); } else { resolve('not_supported') } }) }
else if (f === 'u') { si.usb().then(data => { if (data !== null) { resolve({ data, title: 'USB' }); } else { resolve('not_supported') } }) }
else if (f === 'U') { si.uuid().then(data => { if (data !== null) { resolve({ data, title: 'UUID' }); } else { resolve('not_supported') } }) }
else if (f === 'v') { si.versions().then(data => { if (data !== null) { resolve({ data, title: 'Versions' }); } else { resolve('not_supported') } }) }
else if (f === 'V') { si.vboxInfo().then(data => { if (data !== null) { resolve({ data, title: 'Virtual Box' }); } else { resolve('not_supported') } }) }
else if (f === 'w') { si.wifiNetworks().then(data => { if (data !== null) { resolve({ data, title: 'WIFI Networks' }); } else { resolve('not_supported') } }) }
else if (f === 'y') { si.system().then(data => { if (data !== null) { resolve({ data, title: 'System' }); } else { resolve('not_supported') } }) }
else if (f === 'Y') { si.battery().then(data => { if (data !== null) { resolve({ data, title: 'Battery' }); } else { resolve('not_supported') } }) }
else if (f === 'z') { si.users().then(data => { if (data !== null) { resolve({ data, title: 'Users' }); } else { resolve('not_supported') } }) }
else if (f === '1') { si.networkInterfaceDefault().then(data => { if (data !== null) { resolve({ data, title: 'NET Iface Default' }); } else { resolve('not_supported') } }) }
else if (f === '2') { si.networkGatewayDefault().then(data => { if (data !== null) { resolve({ data, title: 'NET Gateway Default' }); } else { resolve('not_supported') } }) }
else if (f === '3') { si.networkInterfaces().then(data => { if (data !== null) { resolve({ data, title: 'NET Interfaces' }); } else { resolve('not_supported') } }) }
else if (f === '4') { si.networkStats().then(data => { if (data !== null) { resolve({ data, title: 'NET Stats' }); } else { resolve('not_supported') } }) }
else if (f === '5') { si.networkConnections().then(data => { if (data !== null) { resolve({ data, title: 'NET Connections' }); } else { resolve('not_supported') } }) }
else if (f === '6') { si.dockerInfo().then(data => { if (data !== null) { resolve({ data, title: 'Docker Info' }); } else { resolve('not_supported') } }) }
else if (f === '7') { si.dockerContainers(true).then(data => { if (data !== null) { resolve({ data, title: 'Docker Containers' }); } else { resolve('not_supported') } }) }
else if (f === '8') { si.dockerContainerStats('1').then(data => { if (data !== null) { resolve({ data, title: 'Docker Cont Stats' }); } else { resolve('not_supported') } }) }
else if (f === '9') { si.dockerContainerProcesses('1').then(data => { if (data !== null) { resolve({ data, title: 'Docker Cont Processes' }); } else { resolve('not_supported') } }) }
else if (f === '0') { si.dockerAll().then(data => { if (data !== null) { resolve({ data, title: 'Docker All' }); } else { resolve('not_supported') } }) }
else if (f === ',') { si.getStaticData().then(data => { if (data !== null) { resolve({ data, title: 'All Static Data' }); } else { resolve('not_supported') } }) }
else if (f === '.') { si.getDynamicData('apache2, postgres').then(data => { if (data !== null) { resolve({ data, title: 'All Dynamic Data' }); } else { resolve('not_supported') } }) }
else if (f === '/') { si.getAllData('apache2, postgres').then(data => { if (data !== null) { resolve({ data, title: 'All Data' }); } else { resolve('not_supported') } }) }
if (f === 'a') { si.audio().then(data => { if (data !== null) { resolve({ data, title: 'Audio' }); } else { resolve('not_supported'); } }); }
else if (f === 'b') { si.bios().then(data => { if (data !== null) { resolve({ data, title: 'BIOS' }); } else { resolve('not_supported'); } }); }
else if (f === 'B') { si.baseboard().then(data => { if (data !== null) { resolve({ data, title: 'Baseboard' }); } else { resolve('not_supported'); } }); }
else if (f === 'C') { si.chassis().then(data => { if (data !== null) { resolve({ data, title: 'Chassis' }); } else { resolve('not_supported'); } }); }
else if (f === 'c') { si.cpu().then(data => { if (data !== null) { resolve({ data, title: 'CPU' }); } else { resolve('not_supported'); } }); }
else if (f === 'd') { si.diskLayout().then(data => { if (data !== null) { resolve({ data, title: 'Disk Layout' }); } else { resolve('not_supported'); } }); }
else if (f === 'D') { si.disksIO().then(data => { if (data !== null) { resolve({ data, title: 'Disks IO' }); } else { resolve('not_supported'); } }); }
else if (f === 'e') { si.blockDevices().then(data => { if (data !== null) { resolve({ data, title: 'Block Devices' }); } else { resolve('not_supported'); } }); }
else if (f === 'E') { si.fsOpenFiles().then(data => { if (data !== null) { resolve({ data, title: 'Open Files' }); } else { resolve('not_supported'); } }); }
else if (f === 'f') { si.fsSize().then(data => { if (data !== null) { resolve({ data, title: 'File System' }); } else { resolve('not_supported'); } }); }
else if (f === 'F') { si.fsStats().then(data => { if (data !== null) { resolve({ data, title: 'FS Stats' }); } else { resolve('not_supported'); } }); }
else if (f === 'g') { si.graphics().then(data => { if (data !== null) { resolve({ data, title: 'Graphics' }); } else { resolve('not_supported'); } }); }
else if (f === 'h') { si.bluetoothDevices().then(data => { if (data !== null) { resolve({ data, title: 'Bluetooth' }); } else { resolve('not_supported'); } }); }
else if (f === 'i') { si.inetLatency().then(data => { if (data !== null) { resolve({ data, title: 'Internet Latency' }); } else { resolve('not_supported'); } }); }
else if (f === 'I') { si.inetChecksite('https://systeminformation.io').then(data => { if (data !== null) { resolve({ data, title: 'Internet Check Site' }); } else { resolve('not_supported'); } }); }
else if (f === 'j') { si.cpuCurrentSpeed().then(data => { if (data !== null) { resolve({ data, title: 'CPU Current Speed' }); } else { resolve('not_supported'); } }); }
else if (f === 'l') { si.currentLoad().then(data => { if (data !== null) { resolve({ data, title: 'CPU Current Load' }); } else { resolve('not_supported'); } }); }
else if (f === 'L') { si.fullLoad().then(data => { if (data !== null) { resolve({ data, title: 'CPU Full Load' }); } else { resolve('not_supported'); } }); }
else if (f === 'm') { si.mem().then(data => { if (data !== null) { resolve({ data, title: 'Memory' }); } else { resolve('not_supported'); } }); }
else if (f === 'M') { si.memLayout().then(data => { if (data !== null) { resolve({ data, title: 'Memory Layout' }); } else { resolve('not_supported'); } }); }
else if (f === 'o') { si.osInfo().then(data => { if (data !== null) { resolve({ data, title: 'OS Info' }); } else { resolve('not_supported'); } }); }
else if (f === 'p') { si.processes().then(data => { if (data !== null) { resolve({ data, title: 'Processes' }); } else { resolve('not_supported'); } }); }
else if (f === 'P') { si.processLoad('postgres, login, apache, mysql, nginx, git').then(data => { if (data !== null) { resolve({ data, title: 'Process Load' }); } else { resolve('not_supported'); } }); }
else if (f === 'r') { si.printer().then(data => { if (data !== null) { resolve({ data, title: 'Printer' }); } else { resolve('not_supported'); } }); }
else if (f === 's') { si.services('apache2, postgres').then(data => { if (data !== null) { resolve({ data, title: 'Services' }); } else { resolve('not_supported'); } }); }
else if (f === 'S') { si.shell().then(data => { if (data !== null) { resolve({ data, title: 'Shell' }); } else { resolve('not_supported'); } }); }
else if (f === 't') { resolve({ data: si.time(), title: 'Time' }); }
else if (f === 'T') { si.cpuTemperature().then(data => { if (data !== null) { resolve({ data, title: 'CPU Temperature' }); } else { resolve('not_supported'); } }); }
else if (f === 'u') { si.usb().then(data => { if (data !== null) { resolve({ data, title: 'USB' }); } else { resolve('not_supported'); } }); }
else if (f === 'U') { si.uuid().then(data => { if (data !== null) { resolve({ data, title: 'UUID' }); } else { resolve('not_supported'); } }); }
else if (f === 'v') { si.versions().then(data => { if (data !== null) { resolve({ data, title: 'Versions' }); } else { resolve('not_supported'); } }); }
else if (f === 'V') { si.vboxInfo().then(data => { if (data !== null) { resolve({ data, title: 'Virtual Box' }); } else { resolve('not_supported'); } }); }
else if (f === 'w') { si.wifiNetworks().then(data => { if (data !== null) { resolve({ data, title: 'WIFI Networks' }); } else { resolve('not_supported'); } }); }
else if (f === 'y') { si.system().then(data => { if (data !== null) { resolve({ data, title: 'System' }); } else { resolve('not_supported'); } }); }
else if (f === 'Y') { si.battery().then(data => { if (data !== null) { resolve({ data, title: 'Battery' }); } else { resolve('not_supported'); } }); }
else if (f === 'z') { si.users().then(data => { if (data !== null) { resolve({ data, title: 'Users' }); } else { resolve('not_supported'); } }); }
else if (f === '1') { si.networkInterfaceDefault().then(data => { if (data !== null) { resolve({ data, title: 'NET Iface Default' }); } else { resolve('not_supported'); } }); }
else if (f === '2') { si.networkGatewayDefault().then(data => { if (data !== null) { resolve({ data, title: 'NET Gateway Default' }); } else { resolve('not_supported'); } }); }
else if (f === '3') { si.networkInterfaces().then(data => { if (data !== null) { resolve({ data, title: 'NET Interfaces' }); } else { resolve('not_supported'); } }); }
else if (f === '4') { si.networkStats().then(data => { if (data !== null) { resolve({ data, title: 'NET Stats' }); } else { resolve('not_supported'); } }); }
else if (f === '5') { si.networkConnections().then(data => { if (data !== null) { resolve({ data, title: 'NET Connections' }); } else { resolve('not_supported'); } }); }
else if (f === '6') { si.dockerInfo().then(data => { if (data !== null) { resolve({ data, title: 'Docker Info' }); } else { resolve('not_supported'); } }); }
else if (f === '7') { si.dockerContainers(true).then(data => { if (data !== null) { resolve({ data, title: 'Docker Containers' }); } else { resolve('not_supported'); } }); }
else if (f === '8') { si.dockerContainerStats('1').then(data => { if (data !== null) { resolve({ data, title: 'Docker Cont Stats' }); } else { resolve('not_supported'); } }); }
else if (f === '9') { si.dockerContainerProcesses('1').then(data => { if (data !== null) { resolve({ data, title: 'Docker Cont Processes' }); } else { resolve('not_supported'); } }); }
else if (f === '0') { si.dockerAll().then(data => { if (data !== null) { resolve({ data, title: 'Docker All' }); } else { resolve('not_supported'); } }); }
else if (f === ',') { si.getStaticData().then(data => { if (data !== null) { resolve({ data, title: 'All Static Data' }); } else { resolve('not_supported'); } }); }
else if (f === '.') { si.getDynamicData('apache2, postgres').then(data => { if (data !== null) { resolve({ data, title: 'All Dynamic Data' }); } else { resolve('not_supported'); } }); }
else if (f === '/') { si.getAllData('apache2, postgres').then(data => { if (data !== null) { resolve({ data, title: 'All Data' }); } else { resolve('not_supported'); } }); }
else if (f === '?') {
const valueObject = {
cpu: '*',
osInfo: 'platform, release',
system: 'model, manufacturer'
};
si.get(valueObject).then(data => resolve({ data, title: 'Get Object' }));
}
si.get(valueObject).then(data => resolve({ data, title: 'Get Object' }))
}
else resolve('no_key');
})
})
else { resolve('no_key'); }
});
});
}
const key = process.argv[2];
@ -74,4 +74,4 @@ const key = process.argv[2];
test(key).then(data => {
console.log(JSON.stringify(data));
})
});

View File

@ -50,7 +50,7 @@ function startDots() {
dot();
timer = setInterval(() => {
dot();
}, 500)
}, 500);
}
function stopDots() {
@ -59,10 +59,10 @@ function stopDots() {
function printTitle(title) {
// https://en.wikipedia.org/wiki/Box_Drawing_(Unicode_block)
title = '' + (' ' + title + ' ').substr(0, 44 - lib_version.length) + 'v: ' + lib_version + ' ┃'
console.log('┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓');
title = '' + (' ' + title + ' ').substr(0, 44 - lib_version.length) + 'v: ' + lib_version + ' │';
console.log('┌────────────────────────────────────────────────┐');
console.log(title);
console.log('┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛');
console.log('└────────────────────────────────────────────────┘');
}
@ -70,7 +70,7 @@ process.stdin.on('keypress', (key, data) => {
// console.log(data);
if (data.name === 'q' && !data.shift) {
// shut down
process.exit()
process.exit();
}
if (!waiting) {
@ -88,10 +88,10 @@ process.stdin.on('keypress', (key, data) => {
} else {
try {
if (stdout.toString().startsWith('"no_key')) {
console.log()
console.log('Menu item not found. Please select valid menu item ... Press q to quit')
console.log();
console.log('Menu item not found. Please select valid menu item ... Press q to quit');
} else if (stdout.toString().startsWith('"not_supported')) {
console.log()
console.log();
console.log('Key: ' + key);
console.log('Not supported');
} else if (stdout.toString()) {
@ -110,7 +110,7 @@ process.stdin.on('keypress', (key, data) => {
console.log();
}
}
})
});
}
});