code cleanup
This commit is contained in:
parent
65d67fe0a6
commit
2b0885220b
13
.eslintrc
13
.eslintrc
@ -9,5 +9,16 @@
|
|||||||
"parserOptions": {
|
"parserOptions": {
|
||||||
"ecmaVersion": 12
|
"ecmaVersion": 12
|
||||||
},
|
},
|
||||||
"rules": {}
|
"rules": {
|
||||||
|
"semi": [
|
||||||
|
"error",
|
||||||
|
"always"
|
||||||
|
],
|
||||||
|
"eqeqeq": "off",
|
||||||
|
"curly": "error",
|
||||||
|
"quotes": [
|
||||||
|
"error",
|
||||||
|
"single"
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
32
lib/audio.js
32
lib/audio.js
@ -29,7 +29,7 @@ const _netbsd = (_platform === 'netbsd');
|
|||||||
const _sunos = (_platform === 'sunos');
|
const _sunos = (_platform === 'sunos');
|
||||||
|
|
||||||
function getLinuxAudioPci() {
|
function getLinuxAudioPci() {
|
||||||
let cmd = 'lspci -v 2>/dev/null'
|
let cmd = 'lspci -v 2>/dev/null';
|
||||||
let result = [];
|
let result = [];
|
||||||
try {
|
try {
|
||||||
const parts = execSync(cmd).toString().split('\n\n');
|
const parts = execSync(cmd).toString().split('\n\n');
|
||||||
@ -38,7 +38,7 @@ function getLinuxAudioPci() {
|
|||||||
if (lines && lines.length && lines[0].toLowerCase().indexOf('audio') >= 0) {
|
if (lines && lines.length && lines[0].toLowerCase().indexOf('audio') >= 0) {
|
||||||
const audio = {};
|
const audio = {};
|
||||||
audio.slotId = lines[0].split(' ')[0];
|
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);
|
result.push(audio);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -52,7 +52,7 @@ function parseLinuxAudioPciMM(lines, audioPCI) {
|
|||||||
const result = {};
|
const result = {};
|
||||||
const slotId = util.getValue(lines, 'Slot');
|
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.id = slotId;
|
||||||
result.name = util.getValue(lines, 'SDevice');
|
result.name = util.getValue(lines, 'SDevice');
|
||||||
@ -87,14 +87,14 @@ function parseDarwinAudio(audioObject, id) {
|
|||||||
const channelStr = ((audioObject.coreaudio_device_transport || '') + ' ' + (audioObject._name || '')).toLowerCase();
|
const channelStr = ((audioObject.coreaudio_device_transport || '') + ' ' + (audioObject._name || '')).toLowerCase();
|
||||||
|
|
||||||
result.id = id;
|
result.id = id;
|
||||||
result.name = audioObject._name
|
result.name = audioObject._name;
|
||||||
result.manufacturer = audioObject.coreaudio_device_manufacturer;
|
result.manufacturer = audioObject.coreaudio_device_manufacturer;
|
||||||
result.revision = null;
|
result.revision = null;
|
||||||
result.driver = null;
|
result.driver = null;
|
||||||
result.default = !!(audioObject.coreaudio_default_audio_input_device || '') || !!(audioObject.coreaudio_default_audio_output_device || '');
|
result.default = !!(audioObject.coreaudio_default_audio_input_device || '') || !!(audioObject.coreaudio_default_audio_output_device || '');
|
||||||
result.channel = parseDarwinChannel(channelStr);
|
result.channel = parseDarwinChannel(channelStr);
|
||||||
result.in = !!(audioObject.coreaudio_device_input || '')
|
result.in = !!(audioObject.coreaudio_device_input || '');
|
||||||
result.out = !!(audioObject.coreaudio_device_output || '')
|
result.out = !!(audioObject.coreaudio_device_output || '');
|
||||||
result.status = 'online';
|
result.status = 'online';
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@ -109,12 +109,12 @@ function parseWindowsAudio(lines) {
|
|||||||
result.name = util.getValue(lines, 'name', '=');
|
result.name = util.getValue(lines, 'name', '=');
|
||||||
result.manufacturer = util.getValue(lines, 'manufacturer', '=');
|
result.manufacturer = util.getValue(lines, 'manufacturer', '=');
|
||||||
result.revision = null;
|
result.revision = null;
|
||||||
result.driver = null
|
result.driver = null;
|
||||||
result.default = null
|
result.default = null;
|
||||||
result.in = null
|
result.in = null;
|
||||||
result.out = null
|
result.out = null;
|
||||||
result.interfaceType = null
|
result.interfaceType = null;
|
||||||
result.status = status
|
result.status = status;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -125,7 +125,7 @@ function audio(callback) {
|
|||||||
process.nextTick(() => {
|
process.nextTick(() => {
|
||||||
let result = [];
|
let result = [];
|
||||||
if (_linux || _freebsd || _openbsd || _netbsd) {
|
if (_linux || _freebsd || _openbsd || _netbsd) {
|
||||||
let cmd = 'lspci -vmm 2>/dev/null'
|
let cmd = 'lspci -vmm 2>/dev/null';
|
||||||
exec(cmd, function (error, stdout) {
|
exec(cmd, function (error, stdout) {
|
||||||
// PCI
|
// PCI
|
||||||
if (!error) {
|
if (!error) {
|
||||||
@ -146,7 +146,7 @@ function audio(callback) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (_darwin) {
|
if (_darwin) {
|
||||||
let cmd = 'system_profiler SPAudioDataType -json'
|
let cmd = 'system_profiler SPAudioDataType -json';
|
||||||
exec(cmd, function (error, stdout) {
|
exec(cmd, function (error, stdout) {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
try {
|
try {
|
||||||
@ -158,7 +158,7 @@ function audio(callback) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
util.noop()
|
util.noop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (callback) {
|
if (callback) {
|
||||||
@ -173,7 +173,7 @@ function audio(callback) {
|
|||||||
const parts = stdout.toString().split(/\n\s*\n/);
|
const parts = stdout.toString().split(/\n\s*\n/);
|
||||||
for (let i = 0; i < parts.length; i++) {
|
for (let i = 0; i < parts.length; i++) {
|
||||||
if (util.getValue(parts[i].split('\n'), 'name', '=')) {
|
if (util.getValue(parts[i].split('\n'), 'name', '=')) {
|
||||||
result.push(parseWindowsAudio(parts[i].split('\n'), i))
|
result.push(parseWindowsAudio(parts[i].split('\n'), i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -64,7 +64,7 @@ function parseDarwinBluetoothDevices(bluetoothObject, macAddr2) {
|
|||||||
result.device = bluetoothObject.device_services || '';
|
result.device = bluetoothObject.device_services || '';
|
||||||
result.name = bluetoothObject.device_name || '';
|
result.name = bluetoothObject.device_name || '';
|
||||||
result.manufacturer = bluetoothObject.device_manufacturer || '';
|
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.macHost = macAddr2;
|
||||||
result.batteryPercent = bluetoothObject.device_batteryPercent || null;
|
result.batteryPercent = bluetoothObject.device_batteryPercent || null;
|
||||||
result.type = parseBluetoothTyoe(typeStr);
|
result.type = parseBluetoothTyoe(typeStr);
|
||||||
@ -124,7 +124,7 @@ function bluetoothDevices(callback) {
|
|||||||
resolve(result);
|
resolve(result);
|
||||||
}
|
}
|
||||||
if (_darwin) {
|
if (_darwin) {
|
||||||
let cmd = 'system_profiler SPBluetoothDataType -json'
|
let cmd = 'system_profiler SPBluetoothDataType -json';
|
||||||
exec(cmd, function (error, stdout) {
|
exec(cmd, function (error, stdout) {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
try {
|
try {
|
||||||
@ -148,7 +148,7 @@ function bluetoothDevices(callback) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
util.noop()
|
util.noop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (callback) {
|
if (callback) {
|
||||||
@ -163,7 +163,7 @@ function bluetoothDevices(callback) {
|
|||||||
const parts = stdout.toString().split(/\n\s*\n/);
|
const parts = stdout.toString().split(/\n\s*\n/);
|
||||||
for (let i = 0; i < parts.length; i++) {
|
for (let i = 0; i < parts.length; i++) {
|
||||||
if (util.getValue(parts[i].split('\n'), 'PNPClass', '=') === 'Bluetooth') {
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -382,7 +382,7 @@ function isUefiWindows() {
|
|||||||
resolve(line.toLowerCase().indexOf('uefi') >= 0);
|
resolve(line.toLowerCase().indexOf('uefi') >= 0);
|
||||||
}
|
}
|
||||||
resolve(false);
|
resolve(false);
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
resolve(false);
|
resolve(false);
|
||||||
});
|
});
|
||||||
|
|||||||
22
lib/util.js
22
lib/util.js
@ -532,7 +532,7 @@ function sanitizeShellString(str) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function isPrototypePolluted() {
|
function isPrototypePolluted() {
|
||||||
const s = '1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
const s = '1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||||
let notPolluted = true;
|
let notPolluted = true;
|
||||||
let st = '';
|
let st = '';
|
||||||
|
|
||||||
@ -541,16 +541,16 @@ function isPrototypePolluted() {
|
|||||||
st.__proto__.toString = stringToString;
|
st.__proto__.toString = stringToString;
|
||||||
st.__proto__.substr = stringSubstr;
|
st.__proto__.substr = stringSubstr;
|
||||||
|
|
||||||
notPolluted = notPolluted || !(s.length === 62)
|
notPolluted = notPolluted || !(s.length === 62);
|
||||||
const ms = Date.now();
|
const ms = Date.now();
|
||||||
if (typeof ms === 'number' && ms > 1600000000000) {
|
if (typeof ms === 'number' && ms > 1600000000000) {
|
||||||
const l = ms % 100 + 15;
|
const l = ms % 100 + 15;
|
||||||
for (let i = 0; i < l; i++) {
|
for (let i = 0; i < l; i++) {
|
||||||
const r = Math.random() * 61.99999999 + 1;
|
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 rs2 = parseInt(r.toString().split('.')[0], 10);
|
||||||
const q = Math.random() * 61.99999999 + 1;
|
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);
|
const qs2 = parseInt(q.toString().split('.')[0], 10);
|
||||||
notPolluted = notPolluted && !(r === q);
|
notPolluted = notPolluted && !(r === q);
|
||||||
notPolluted = notPolluted && rs === rs2 && qs === qs2;
|
notPolluted = notPolluted && rs === rs2 && qs === qs2;
|
||||||
@ -578,7 +578,7 @@ function isPrototypePolluted() {
|
|||||||
|
|
||||||
// lower
|
// lower
|
||||||
const stl = st.toLowerCase();
|
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++) {
|
for (let i = 0; i < l; i++) {
|
||||||
const s1 = st[i];
|
const s1 = st[i];
|
||||||
s1.__proto__.toLowerCase = stringToLower;
|
s1.__proto__.toLowerCase = stringToLower;
|
||||||
@ -591,7 +591,7 @@ function isPrototypePolluted() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function hex2bin(hex) {
|
function hex2bin(hex) {
|
||||||
return ("00000000" + (parseInt(hex, 16)).toString(2)).substr(-8);
|
return ('00000000' + (parseInt(hex, 16)).toString(2)).substr(-8);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getFilesInPath(source) {
|
function getFilesInPath(source) {
|
||||||
@ -605,10 +605,10 @@ function getFilesInPath(source) {
|
|||||||
function isFile(source) { return lstatSync(source).isFile(); }
|
function isFile(source) { return lstatSync(source).isFile(); }
|
||||||
|
|
||||||
function getDirectories(source) {
|
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) {
|
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) {
|
function getFilesRecursively(source) {
|
||||||
@ -750,7 +750,7 @@ function decodePiCpuinfo(lines) {
|
|||||||
manufacturer: '512MB Embest',
|
manufacturer: '512MB Embest',
|
||||||
processor: 'BCM2835'
|
processor: 'BCM2835'
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
const processorList = [
|
const processorList = [
|
||||||
'BCM2835',
|
'BCM2835',
|
||||||
@ -803,7 +803,7 @@ function decodePiCpuinfo(lines) {
|
|||||||
processor: oldRevisionCodes[revisionCode].processor,
|
processor: oldRevisionCodes[revisionCode].processor,
|
||||||
type: oldRevisionCodes[revisionCode].type,
|
type: oldRevisionCodes[revisionCode].type,
|
||||||
revision: oldRevisionCodes[revisionCode].revision,
|
revision: oldRevisionCodes[revisionCode].revision,
|
||||||
}
|
};
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// new revision code
|
// new revision code
|
||||||
@ -824,7 +824,7 @@ function decodePiCpuinfo(lines) {
|
|||||||
processor,
|
processor,
|
||||||
type: {}.hasOwnProperty.call(typeList, typeCode) ? typeList[typeCode] : '',
|
type: {}.hasOwnProperty.call(typeList, typeCode) ? typeList[typeCode] : '',
|
||||||
revision: '1.' + revision.substr(7, 1),
|
revision: '1.' + revision.substr(7, 1),
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "systeminformation",
|
"name": "systeminformation",
|
||||||
"version": "4.34.9",
|
"version": "4.34.9",
|
||||||
"prereleaseversion": "5.0-alpha.0116",
|
"prereleaseversion": "5.0-alpha.0117",
|
||||||
"description": "Simple system and OS information library",
|
"description": "Simple system and OS information library",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"author": "Sebastian Hildebrandt <hildebrandt@plus-innovations.com> (https://plus-innovations.com)",
|
"author": "Sebastian Hildebrandt <hildebrandt@plus-innovations.com> (https://plus-innovations.com)",
|
||||||
|
|||||||
110
test/si.js
110
test/si.js
@ -5,66 +5,66 @@ function test(f) {
|
|||||||
process.nextTick(() => {
|
process.nextTick(() => {
|
||||||
f = f.replace(/'/g, '');
|
f = f.replace(/'/g, '');
|
||||||
// console.log(f);
|
// console.log(f);
|
||||||
if (f === 'a') { si.audio().then(data => { if (data !== null) { resolve({ data, title: 'Audio' }); } 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.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 === '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.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 === '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.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 === '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.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 === '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.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 === '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 === '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 === '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.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 === '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 === '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.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 === '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.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 === '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 === '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.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 === '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 === '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.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 === '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') { 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 === '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.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 === '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.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 === '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 === '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.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 === '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 === '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 === '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 === '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 === '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 === '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 === '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 === '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 === '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 === '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 === '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 === '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.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.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 === '/') { si.getAllData('apache2, postgres').then(data => { if (data !== null) { resolve({ data, title: 'All Data' }); } else { resolve('not_supported'); } }); }
|
||||||
else if (f === '?') {
|
else if (f === '?') {
|
||||||
const valueObject = {
|
const valueObject = {
|
||||||
cpu: '*',
|
cpu: '*',
|
||||||
osInfo: 'platform, release',
|
osInfo: 'platform, release',
|
||||||
system: 'model, manufacturer'
|
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];
|
const key = process.argv[2];
|
||||||
@ -74,4 +74,4 @@ const key = process.argv[2];
|
|||||||
|
|
||||||
test(key).then(data => {
|
test(key).then(data => {
|
||||||
console.log(JSON.stringify(data));
|
console.log(JSON.stringify(data));
|
||||||
})
|
});
|
||||||
|
|||||||
20
test/test.js
20
test/test.js
@ -50,7 +50,7 @@ function startDots() {
|
|||||||
dot();
|
dot();
|
||||||
timer = setInterval(() => {
|
timer = setInterval(() => {
|
||||||
dot();
|
dot();
|
||||||
}, 500)
|
}, 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
function stopDots() {
|
function stopDots() {
|
||||||
@ -59,10 +59,10 @@ function stopDots() {
|
|||||||
|
|
||||||
function printTitle(title) {
|
function printTitle(title) {
|
||||||
// https://en.wikipedia.org/wiki/Box_Drawing_(Unicode_block)
|
// https://en.wikipedia.org/wiki/Box_Drawing_(Unicode_block)
|
||||||
title = '┃' + (' ' + title + ' ').substr(0, 44 - lib_version.length) + 'v: ' + lib_version + ' ┃'
|
title = '│' + (' ' + title + ' ').substr(0, 44 - lib_version.length) + 'v: ' + lib_version + ' │';
|
||||||
console.log('┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓');
|
console.log('┌────────────────────────────────────────────────┐');
|
||||||
console.log(title);
|
console.log(title);
|
||||||
console.log('┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛');
|
console.log('└────────────────────────────────────────────────┘');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,14 +70,14 @@ process.stdin.on('keypress', (key, data) => {
|
|||||||
// console.log(data);
|
// console.log(data);
|
||||||
if (data.name === 'q' && !data.shift) {
|
if (data.name === 'q' && !data.shift) {
|
||||||
// shut down
|
// shut down
|
||||||
process.exit()
|
process.exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!waiting) {
|
if (!waiting) {
|
||||||
waiting = true;
|
waiting = true;
|
||||||
startDots();
|
startDots();
|
||||||
const siPath = path.join(__dirname, 'si.js');
|
const siPath = path.join(__dirname, 'si.js');
|
||||||
exec(`node ${siPath} '${key}'`, {timeout: 30000}, (error, stdout) => {
|
exec(`node ${siPath} '${key}'`, { timeout: 30000 }, (error, stdout) => {
|
||||||
waiting = false;
|
waiting = false;
|
||||||
stopDots();
|
stopDots();
|
||||||
clearline();
|
clearline();
|
||||||
@ -88,10 +88,10 @@ process.stdin.on('keypress', (key, data) => {
|
|||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
if (stdout.toString().startsWith('"no_key')) {
|
if (stdout.toString().startsWith('"no_key')) {
|
||||||
console.log()
|
console.log();
|
||||||
console.log('Menu item not found. Please select valid menu item ... Press q to quit')
|
console.log('Menu item not found. Please select valid menu item ... Press q to quit');
|
||||||
} else if (stdout.toString().startsWith('"not_supported')) {
|
} else if (stdout.toString().startsWith('"not_supported')) {
|
||||||
console.log()
|
console.log();
|
||||||
console.log('Key: ' + key);
|
console.log('Key: ' + key);
|
||||||
console.log('Not supported');
|
console.log('Not supported');
|
||||||
} else if (stdout.toString()) {
|
} else if (stdout.toString()) {
|
||||||
@ -110,7 +110,7 @@ process.stdin.on('keypress', (key, data) => {
|
|||||||
console.log();
|
console.log();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user