added windows exec 'windowsHide' option
This commit is contained in:
parent
fc7348cc56
commit
a15af92453
@ -11,9 +11,6 @@ end_of_line = lf
|
|||||||
indent_style = space
|
indent_style = space
|
||||||
indent_size = 2
|
indent_size = 2
|
||||||
insert_final_newline = true
|
insert_final_newline = true
|
||||||
# trim_trailing_whitespace = true
|
|
||||||
|
|
||||||
[*.md]
|
|
||||||
trim_trailing_whitespace = true
|
trim_trailing_whitespace = true
|
||||||
|
|
||||||
[{.travis.yml,package.json}]
|
[{.travis.yml,package.json}]
|
||||||
|
|||||||
@ -100,6 +100,7 @@ Other changes
|
|||||||
|
|
||||||
| Version | Date | Comment |
|
| Version | Date | Comment |
|
||||||
| -------------- | -------------- | -------- |
|
| -------------- | -------------- | -------- |
|
||||||
|
| 3.37.3 | 2018-02-19 | added windows exec 'windowsHide' option |
|
||||||
| 3.37.2 | 2018-02-15 | fixed bug `battery().percent` for macOS |
|
| 3.37.2 | 2018-02-15 | fixed bug `battery().percent` for macOS |
|
||||||
| 3.37.1 | 2018-02-13 | fixed bug `battery().ischarging` for macOS |
|
| 3.37.1 | 2018-02-13 | fixed bug `battery().ischarging` for macOS |
|
||||||
| 3.37.0 | 2018-02-11 | extended FreeBSD support `networkStats()` |
|
| 3.37.0 | 2018-02-11 | extended FreeBSD support `networkStats()` |
|
||||||
|
|||||||
@ -559,6 +559,7 @@ Written by Sebastian Hildebrandt [sebhildebrandt](https://github.com/sebhildebra
|
|||||||
- Tiago Roldão [tiagoroldao](https://github.com/tiagoroldao)
|
- Tiago Roldão [tiagoroldao](https://github.com/tiagoroldao)
|
||||||
- dragonjet [dragonjet](https://github.com/dragonjet)
|
- dragonjet [dragonjet](https://github.com/dragonjet)
|
||||||
- Adam Reis [adamreisnz](https://github.com/adamreisnz)
|
- Adam Reis [adamreisnz](https://github.com/adamreisnz)
|
||||||
|
- Jimmi M [ItsJimi](https://github.com/ItsJimi)
|
||||||
|
|
||||||
OSX Temperature: credits here are going to:
|
OSX Temperature: credits here are going to:
|
||||||
|
|
||||||
|
|||||||
@ -24,6 +24,10 @@ const _windows = (_platform === 'win32');
|
|||||||
const _freebsd = (_platform === 'freebsd');
|
const _freebsd = (_platform === 'freebsd');
|
||||||
const _openbsd = (_platform === 'openbsd');
|
const _openbsd = (_platform === 'openbsd');
|
||||||
|
|
||||||
|
const opts = {
|
||||||
|
windowsHide: true
|
||||||
|
};
|
||||||
|
|
||||||
module.exports = function (callback) {
|
module.exports = function (callback) {
|
||||||
|
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
@ -123,7 +127,7 @@ module.exports = function (callback) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (_windows) {
|
if (_windows) {
|
||||||
exec(util.getWmic() + ' Path Win32_Battery Get BatteryStatus, DesignCapacity, EstimatedChargeRemaining /value', function (error, stdout) {
|
exec(util.getWmic() + ' Path Win32_Battery Get BatteryStatus, DesignCapacity, EstimatedChargeRemaining /value', opts, function (error, stdout) {
|
||||||
if (stdout) {
|
if (stdout) {
|
||||||
let lines = stdout.split('\r\n');
|
let lines = stdout.split('\r\n');
|
||||||
let status = util.getValue(lines, 'BatteryStatus', '=').trim();
|
let status = util.getValue(lines, 'BatteryStatus', '=').trim();
|
||||||
|
|||||||
@ -25,6 +25,10 @@ const _windows = (_platform === 'win32');
|
|||||||
const _freebsd = (_platform === 'freebsd');
|
const _freebsd = (_platform === 'freebsd');
|
||||||
const _openbsd = (_platform === 'openbsd');
|
const _openbsd = (_platform === 'openbsd');
|
||||||
|
|
||||||
|
const opts = {
|
||||||
|
windowsHide: true
|
||||||
|
};
|
||||||
|
|
||||||
let _cpu_speed = '0.00';
|
let _cpu_speed = '0.00';
|
||||||
let _current_cpu = {
|
let _current_cpu = {
|
||||||
user: 0,
|
user: 0,
|
||||||
@ -298,7 +302,7 @@ function getCpu() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (_windows) {
|
if (_windows) {
|
||||||
exec(util.getWmic() + ' cpu get name, description, revision, l2cachesize, l3cachesize, manufacturer, currentclockspeed, maxclockspeed /value', function (error, stdout) {
|
exec(util.getWmic() + ' cpu get name, description, revision, l2cachesize, l3cachesize, manufacturer, currentclockspeed, maxclockspeed /value', opts, function (error, stdout) {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
let lines = stdout.split('\r\n');
|
let lines = stdout.split('\r\n');
|
||||||
let name = util.getValue(lines, 'name', '=') || '';
|
let name = util.getValue(lines, 'name', '=') || '';
|
||||||
@ -534,7 +538,7 @@ function cpuTemperature(callback) {
|
|||||||
resolve(result);
|
resolve(result);
|
||||||
}
|
}
|
||||||
if (_windows) {
|
if (_windows) {
|
||||||
exec(util.getWmic() + ' /namespace:\\\\root\\wmi PATH MSAcpi_ThermalZoneTemperature get CurrentTemperature', function (error, stdout) {
|
exec(util.getWmic() + ' /namespace:\\\\root\\wmi PATH MSAcpi_ThermalZoneTemperature get CurrentTemperature', opts, function (error, stdout) {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
let sum = 0;
|
let sum = 0;
|
||||||
let lines = stdout.split('\r\n').filter(line => line.trim() !== '').filter((line, idx) => idx > 0);
|
let lines = stdout.split('\r\n').filter(line => line.trim() !== '').filter((line, idx) => idx > 0);
|
||||||
|
|||||||
@ -26,6 +26,10 @@ const _openbsd = (_platform === 'openbsd');
|
|||||||
|
|
||||||
const NOT_SUPPORTED = 'not supported';
|
const NOT_SUPPORTED = 'not supported';
|
||||||
|
|
||||||
|
const opts = {
|
||||||
|
windowsHide: true
|
||||||
|
};
|
||||||
|
|
||||||
let _fs_speed = {};
|
let _fs_speed = {};
|
||||||
let _disk_io = {};
|
let _disk_io = {};
|
||||||
|
|
||||||
@ -69,7 +73,7 @@ function fsSize(callback) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (_windows) {
|
if (_windows) {
|
||||||
exec(util.getWmic() + ' logicaldisk get Caption,FileSystem,FreeSpace,Size', function (error, stdout) {
|
exec(util.getWmic() + ' logicaldisk get Caption,FileSystem,FreeSpace,Size', opts, function (error, stdout) {
|
||||||
let lines = stdout.split('\r\n').filter(line => line.trim() !== '').filter((line, idx) => idx > 0);
|
let lines = stdout.split('\r\n').filter(line => line.trim() !== '').filter((line, idx) => idx > 0);
|
||||||
lines.forEach(function (line) {
|
lines.forEach(function (line) {
|
||||||
if (line !== '') {
|
if (line !== '') {
|
||||||
@ -245,7 +249,7 @@ function blockDevices(callback) {
|
|||||||
}
|
}
|
||||||
if (_windows) {
|
if (_windows) {
|
||||||
let drivetypes = ['Unknown', 'NoRoot', 'Removable', 'HDD', 'Network', 'CD/DVD', 'RAM'];
|
let drivetypes = ['Unknown', 'NoRoot', 'Removable', 'HDD', 'Network', 'CD/DVD', 'RAM'];
|
||||||
exec(util.getWmic() + ' logicaldisk get Caption,Description,DeviceID,DriveType,FileSystem,FreeSpace,Name,Size,VolumeName,VolumeSerialNumber /value', function (error, stdout) {
|
exec(util.getWmic() + ' logicaldisk get Caption,Description,DeviceID,DriveType,FileSystem,FreeSpace,Name,Size,VolumeName,VolumeSerialNumber /value', opts, function (error, stdout) {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
let devices = stdout.toString().split(/\n\s*\n/);
|
let devices = stdout.toString().split(/\n\s*\n/);
|
||||||
devices.forEach(function (device) {
|
devices.forEach(function (device) {
|
||||||
@ -712,7 +716,7 @@ function diskLayout(callback) {
|
|||||||
}
|
}
|
||||||
if (_windows) {
|
if (_windows) {
|
||||||
|
|
||||||
exec(util.getWmic() + ' diskdrive get /value', {encoding: 'utf8'}, function (error, stdout) {
|
exec(util.getWmic() + ' diskdrive get /value', {encoding: 'utf8'}, opts, function (error, stdout) {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
let devices = stdout.toString().split(/\n\s*\n/);
|
let devices = stdout.toString().split(/\n\s*\n/);
|
||||||
devices.forEach(function (device) {
|
devices.forEach(function (device) {
|
||||||
|
|||||||
@ -23,6 +23,10 @@ const _windows = (_platform === 'win32');
|
|||||||
const _freebsd = (_platform === 'freebsd');
|
const _freebsd = (_platform === 'freebsd');
|
||||||
const _openbsd = (_platform === 'openbsd');
|
const _openbsd = (_platform === 'openbsd');
|
||||||
|
|
||||||
|
const opts = {
|
||||||
|
windowsHide: true
|
||||||
|
};
|
||||||
|
|
||||||
let _resolutionx = 0;
|
let _resolutionx = 0;
|
||||||
let _resolutiony = 0;
|
let _resolutiony = 0;
|
||||||
let _pixeldepth = 0;
|
let _pixeldepth = 0;
|
||||||
@ -329,11 +333,11 @@ function graphics(callback) {
|
|||||||
}
|
}
|
||||||
if (_windows) {
|
if (_windows) {
|
||||||
// https://blogs.technet.microsoft.com/heyscriptingguy/2013/10/03/use-powershell-to-discover-multi-monitor-information/
|
// https://blogs.technet.microsoft.com/heyscriptingguy/2013/10/03/use-powershell-to-discover-multi-monitor-information/
|
||||||
exec(util.getWmic() + ' path win32_VideoController get AdapterCompatibility, AdapterDACType, name, PNPDeviceID, CurrentVerticalResolution, CurrentHorizontalResolution, CurrentNumberOfColors, AdapterRAM, CurrentBitsPerPixel, CurrentRefreshRate, MinRefreshRate, MaxRefreshRate, VideoMemoryType /value', function (error, stdout) {
|
exec(util.getWmic() + ' path win32_VideoController get AdapterCompatibility, AdapterDACType, name, PNPDeviceID, CurrentVerticalResolution, CurrentHorizontalResolution, CurrentNumberOfColors, AdapterRAM, CurrentBitsPerPixel, CurrentRefreshRate, MinRefreshRate, MaxRefreshRate, VideoMemoryType /value', opts, function (error, stdout) {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
let csections = stdout.split(/\n\s*\n/);
|
let csections = stdout.split(/\n\s*\n/);
|
||||||
result.controllers = parseLinesWindowsControllers(csections);
|
result.controllers = parseLinesWindowsControllers(csections);
|
||||||
exec(util.getWmic() + ' path win32_desktopmonitor get Caption, MonitorManufacturer, MonitorType, ScreenWidth, ScreenHeight /value', function (error, stdout) {
|
exec(util.getWmic() + ' path win32_desktopmonitor get Caption, MonitorManufacturer, MonitorType, ScreenWidth, ScreenHeight /value', opts, function (error, stdout) {
|
||||||
let dsections = stdout.split(/\n\s*\n/);
|
let dsections = stdout.split(/\n\s*\n/);
|
||||||
if (!error) {
|
if (!error) {
|
||||||
result.displays = parseLinesWindowsDisplays(dsections);
|
result.displays = parseLinesWindowsDisplays(dsections);
|
||||||
|
|||||||
@ -24,6 +24,9 @@ const _windows = (_platform === 'win32');
|
|||||||
const _freebsd = (_platform === 'freebsd');
|
const _freebsd = (_platform === 'freebsd');
|
||||||
const _openbsd = (_platform === 'openbsd');
|
const _openbsd = (_platform === 'openbsd');
|
||||||
|
|
||||||
|
const opts = {
|
||||||
|
windowsHide: true
|
||||||
|
};
|
||||||
|
|
||||||
const OSX_RAM_manufacturers = {
|
const OSX_RAM_manufacturers = {
|
||||||
'0x014F': 'Transcend Information',
|
'0x014F': 'Transcend Information',
|
||||||
@ -191,7 +194,7 @@ function mem(callback) {
|
|||||||
if (_windows) {
|
if (_windows) {
|
||||||
let swaptotal = 0;
|
let swaptotal = 0;
|
||||||
let swapused = 0;
|
let swapused = 0;
|
||||||
exec(util.getWmic() + ' pagefile get AllocatedBaseSize, CurrentUsage', function (error, stdout) {
|
exec(util.getWmic() + ' pagefile get AllocatedBaseSize, CurrentUsage', opts, function (error, stdout) {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
let lines = stdout.split('\r\n').filter(line => line.trim() !== '').filter((line, idx) => idx > 0);
|
let lines = stdout.split('\r\n').filter(line => line.trim() !== '').filter((line, idx) => idx > 0);
|
||||||
lines.forEach(function (line) {
|
lines.forEach(function (line) {
|
||||||
@ -320,7 +323,7 @@ function memLayout(callback) {
|
|||||||
const memoryTypes = 'Unknown|Other|DRAM|Synchronous DRAM|Cache DRAM|EDO|EDRAM|VRAM|SRAM|RAM|ROM|FLASH|EEPROM|FEPROM|EPROM|CDRAM|3DRAM|SDRAM|SGRAM|RDRAM|DDR|DDR2|DDR2 FB-DIMM|Reserved|DDR3|FBD2|DDR4|LPDDR|LPDDR2|LPDDR3|LPDDR4'.split('|');
|
const memoryTypes = 'Unknown|Other|DRAM|Synchronous DRAM|Cache DRAM|EDO|EDRAM|VRAM|SRAM|RAM|ROM|FLASH|EEPROM|FEPROM|EPROM|CDRAM|3DRAM|SDRAM|SGRAM|RDRAM|DDR|DDR2|DDR2 FB-DIMM|Reserved|DDR3|FBD2|DDR4|LPDDR|LPDDR2|LPDDR3|LPDDR4'.split('|');
|
||||||
const FormFactors = 'Unknown|Other|SIP|DIP|ZIP|SOJ|Proprietary|SIMM|DIMM|TSOP|PGA|RIMM|SODIMM|SRIMM|SMD|SSMP|QFP|TQFP|SOIC|LCC|PLCC|BGA|FPBGA|LGA'.split('|');
|
const FormFactors = 'Unknown|Other|SIP|DIP|ZIP|SOJ|Proprietary|SIMM|DIMM|TSOP|PGA|RIMM|SODIMM|SRIMM|SMD|SSMP|QFP|TQFP|SOIC|LCC|PLCC|BGA|FPBGA|LGA'.split('|');
|
||||||
|
|
||||||
exec(util.getWmic() + ' memorychip get BankLabel, Capacity, ConfiguredClockSpeed, ConfiguredVoltage, MaxVoltage, MinVoltage, DataWidth, FormFactor, Manufacturer, MemoryType, PartNumber, SerialNumber, Speed, Tag /value', function (error, stdout) {
|
exec(util.getWmic() + ' memorychip get BankLabel, Capacity, ConfiguredClockSpeed, ConfiguredVoltage, MaxVoltage, MinVoltage, DataWidth, FormFactor, Manufacturer, MemoryType, PartNumber, SerialNumber, Speed, Tag /value', opts, function (error, stdout) {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
let devices = stdout.toString().split('BankL');
|
let devices = stdout.toString().split('BankL');
|
||||||
devices.shift();
|
devices.shift();
|
||||||
|
|||||||
@ -26,6 +26,10 @@ const _windows = (_platform === 'win32');
|
|||||||
const _freebsd = (_platform === 'freebsd');
|
const _freebsd = (_platform === 'freebsd');
|
||||||
const _openbsd = (_platform === 'openbsd');
|
const _openbsd = (_platform === 'openbsd');
|
||||||
|
|
||||||
|
const opts = {
|
||||||
|
windowsHide: true
|
||||||
|
};
|
||||||
|
|
||||||
let _network = {};
|
let _network = {};
|
||||||
let _default_iface;
|
let _default_iface;
|
||||||
let _mac = {};
|
let _mac = {};
|
||||||
@ -349,14 +353,14 @@ function networkStats(iface, callback) {
|
|||||||
let perfData = [];
|
let perfData = [];
|
||||||
let nics = [];
|
let nics = [];
|
||||||
cmd = util.getWmic() + ' nic get MACAddress, name, NetEnabled /value';
|
cmd = util.getWmic() + ' nic get MACAddress, name, NetEnabled /value';
|
||||||
exec(cmd, function (error, stdout) {
|
exec(cmd, opts, function (error, stdout) {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
const nsections = stdout.split(/\n\s*\n/);
|
const nsections = stdout.split(/\n\s*\n/);
|
||||||
nics = parseLinesWindowsNics(nsections);
|
nics = parseLinesWindowsNics(nsections);
|
||||||
|
|
||||||
// Performance Data
|
// Performance Data
|
||||||
cmd = util.getWmic() + ' path Win32_PerfRawData_Tcpip_NetworkInterface Get name,BytesReceivedPersec,BytesSentPersec,BytesTotalPersec /value';
|
cmd = util.getWmic() + ' path Win32_PerfRawData_Tcpip_NetworkInterface Get name,BytesReceivedPersec,BytesSentPersec,BytesTotalPersec /value';
|
||||||
exec(cmd, function (error, stdout) {
|
exec(cmd, opts, function (error, stdout) {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
const psections = stdout.split(/\n\s*\n/);
|
const psections = stdout.split(/\n\s*\n/);
|
||||||
perfData = parseLinesWindowsPerfData(psections);
|
perfData = parseLinesWindowsPerfData(psections);
|
||||||
@ -565,7 +569,7 @@ function networkConnections(callback) {
|
|||||||
}
|
}
|
||||||
if (_windows) {
|
if (_windows) {
|
||||||
let cmd = 'netstat -na';
|
let cmd = 'netstat -na';
|
||||||
exec(cmd, function (error, stdout) {
|
exec(cmd, opts, function (error, stdout) {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
|
|
||||||
let lines = stdout.toString().split('\r\n');
|
let lines = stdout.toString().split('\r\n');
|
||||||
|
|||||||
@ -24,6 +24,10 @@ const _windows = (_platform === 'win32');
|
|||||||
const _freebsd = (_platform === 'freebsd');
|
const _freebsd = (_platform === 'freebsd');
|
||||||
const _openbsd = (_platform === 'openbsd');
|
const _openbsd = (_platform === 'openbsd');
|
||||||
|
|
||||||
|
const opts = {
|
||||||
|
windowsHide: true
|
||||||
|
};
|
||||||
|
|
||||||
const NOT_SUPPORTED = 'not supported';
|
const NOT_SUPPORTED = 'not supported';
|
||||||
|
|
||||||
// --------------------------
|
// --------------------------
|
||||||
@ -226,7 +230,7 @@ function osInfo(callback) {
|
|||||||
if (_windows) {
|
if (_windows) {
|
||||||
result.logofile = getLogoFile();
|
result.logofile = getLogoFile();
|
||||||
result.release = result.kernel;
|
result.release = result.kernel;
|
||||||
exec(util.getWmic() + ' os get Caption', function (error, stdout) {
|
exec(util.getWmic() + ' os get Caption', opts, function (error, stdout) {
|
||||||
result.distro = result.codename = stdout.slice(stdout.indexOf('\r\n') + 2).trim();
|
result.distro = result.codename = stdout.slice(stdout.indexOf('\r\n') + 2).trim();
|
||||||
if (callback) {
|
if (callback) {
|
||||||
callback(result);
|
callback(result);
|
||||||
|
|||||||
@ -24,6 +24,10 @@ const _windows = (_platform === 'win32');
|
|||||||
const _freebsd = (_platform === 'freebsd');
|
const _freebsd = (_platform === 'freebsd');
|
||||||
const _openbsd = (_platform === 'openbsd');
|
const _openbsd = (_platform === 'openbsd');
|
||||||
|
|
||||||
|
const opts = {
|
||||||
|
windowsHide: true
|
||||||
|
};
|
||||||
|
|
||||||
const NOT_SUPPORTED = 'not supported';
|
const NOT_SUPPORTED = 'not supported';
|
||||||
|
|
||||||
let _process_cpu = {
|
let _process_cpu = {
|
||||||
@ -120,7 +124,7 @@ function services(srv, callback) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (_windows) {
|
if (_windows) {
|
||||||
exec(util.getWmic() + ' service get /value', {maxBuffer: 1024 * 1000}, function (error, stdout) {
|
exec(util.getWmic() + ' service get /value', {maxBuffer: 1024 * 1000}, opts, function (error, stdout) {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
let serviceSections = stdout.split(/\n\s*\n/);
|
let serviceSections = stdout.split(/\n\s*\n/);
|
||||||
for (let i = 0; i < serviceSections.length; i++) {
|
for (let i = 0; i < serviceSections.length; i++) {
|
||||||
@ -489,7 +493,7 @@ function processes(callback) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (_windows) {
|
if (_windows) {
|
||||||
exec(util.getWmic() + ' process get /value', {maxBuffer: 1024 * 1000}, function (error, stdout) {
|
exec(util.getWmic() + ' process get /value', {maxBuffer: 1024 * 1000}, opts, function (error, stdout) {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
let processSections = stdout.split(/\n\s*\n/);
|
let processSections = stdout.split(/\n\s*\n/);
|
||||||
let procs = [];
|
let procs = [];
|
||||||
|
|||||||
@ -24,6 +24,10 @@ const _windows = (_platform === 'win32');
|
|||||||
const _freebsd = (_platform === 'freebsd');
|
const _freebsd = (_platform === 'freebsd');
|
||||||
const _openbsd = (_platform === 'openbsd');
|
const _openbsd = (_platform === 'openbsd');
|
||||||
|
|
||||||
|
const opts = {
|
||||||
|
windowsHide: true
|
||||||
|
};
|
||||||
|
|
||||||
function system(callback) {
|
function system(callback) {
|
||||||
|
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
@ -161,7 +165,7 @@ function system(callback) {
|
|||||||
if (_windows) {
|
if (_windows) {
|
||||||
// exec('wmic csproduct get', function (error, stdout) {
|
// exec('wmic csproduct get', function (error, stdout) {
|
||||||
// ToDo: refactor /value
|
// ToDo: refactor /value
|
||||||
exec(util.getWmic() + ' csproduct get /value', function (error, stdout) {
|
exec(util.getWmic() + ' csproduct get /value', opts, function (error, stdout) {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
// let lines = stdout.split('\r\n').filter(line => line.trim() !== '').filter((line, idx) => idx > 0)[0].trim().split(/\s\s+/);
|
// let lines = stdout.split('\r\n').filter(line => line.trim() !== '').filter((line, idx) => idx > 0)[0].trim().split(/\s\s+/);
|
||||||
let lines = stdout.split('\r\n');
|
let lines = stdout.split('\r\n');
|
||||||
@ -222,7 +226,7 @@ function bios(callback) {
|
|||||||
}
|
}
|
||||||
if (_windows) {
|
if (_windows) {
|
||||||
// ToDo: check BIOS windows
|
// ToDo: check BIOS windows
|
||||||
exec(util.getWmic() + ' bios get /value', function (error, stdout) {
|
exec(util.getWmic() + ' bios get /value', opts, function (error, stdout) {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
let lines = stdout.toString().split('\r\n');
|
let lines = stdout.toString().split('\r\n');
|
||||||
const description = util.getValue(lines, 'description', '=');
|
const description = util.getValue(lines, 'description', '=');
|
||||||
@ -308,7 +312,7 @@ function baseboard(callback) {
|
|||||||
}
|
}
|
||||||
if (_windows) {
|
if (_windows) {
|
||||||
// ToDo: check BIOS windows
|
// ToDo: check BIOS windows
|
||||||
exec(util.getWmic() + ' baseboard get /value', function (error, stdout) {
|
exec(util.getWmic() + ' baseboard get /value', opts, function (error, stdout) {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
let lines = stdout.toString().split('\r\n');
|
let lines = stdout.toString().split('\r\n');
|
||||||
|
|
||||||
|
|||||||
@ -23,6 +23,10 @@ const _windows = (_platform === 'win32');
|
|||||||
const _freebsd = (_platform === 'freebsd');
|
const _freebsd = (_platform === 'freebsd');
|
||||||
const _openbsd = (_platform === 'openbsd');
|
const _openbsd = (_platform === 'openbsd');
|
||||||
|
|
||||||
|
const opts = {
|
||||||
|
windowsHide: true
|
||||||
|
};
|
||||||
|
|
||||||
// --------------------------
|
// --------------------------
|
||||||
// array of users online = sessions
|
// array of users online = sessions
|
||||||
|
|
||||||
@ -229,7 +233,7 @@ function users(callback) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (_windows) {
|
if (_windows) {
|
||||||
exec('query user', function (error, stdout) {
|
exec('query user', opts, function (error, stdout) {
|
||||||
if (stdout) {
|
if (stdout) {
|
||||||
// lines / split
|
// lines / split
|
||||||
let lines = stdout.toString().split('\r\n');
|
let lines = stdout.toString().split('\r\n');
|
||||||
|
|||||||
36
lib/util.js
36
lib/util.js
@ -23,29 +23,29 @@ function isFunction(functionToCheck) {
|
|||||||
return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
|
return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
|
||||||
}
|
}
|
||||||
|
|
||||||
function unique(obj){
|
function unique(obj) {
|
||||||
let uniques=[];
|
let uniques = [];
|
||||||
let stringify={};
|
let stringify = {};
|
||||||
for(let i=0;i<obj.length;i++){
|
for (let i = 0; i < obj.length; i++) {
|
||||||
let keys=Object.keys(obj[i]);
|
let keys = Object.keys(obj[i]);
|
||||||
keys.sort(function(a,b) { return a-b; });
|
keys.sort(function (a, b) { return a - b; });
|
||||||
let str='';
|
let str = '';
|
||||||
for(let j=0;j<keys.length;j++){
|
for (let j = 0; j < keys.length; j++) {
|
||||||
str+= JSON.stringify(keys[j]);
|
str += JSON.stringify(keys[j]);
|
||||||
str+= JSON.stringify(obj[i][keys[j]]);
|
str += JSON.stringify(obj[i][keys[j]]);
|
||||||
}
|
}
|
||||||
if(!stringify.hasOwnProperty(str)){
|
if (!stringify.hasOwnProperty(str)) {
|
||||||
uniques.push(obj[i]);
|
uniques.push(obj[i]);
|
||||||
stringify[str]=true;
|
stringify[str] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return uniques;
|
return uniques;
|
||||||
}
|
}
|
||||||
|
|
||||||
function sortByKey(array, keys) {
|
function sortByKey(array, keys) {
|
||||||
return array.sort(function(a, b) {
|
return array.sort(function (a, b) {
|
||||||
let x ='';
|
let x = '';
|
||||||
let y ='';
|
let y = '';
|
||||||
keys.forEach(function (key) {
|
keys.forEach(function (key) {
|
||||||
x = x + a[key]; y = y + b[key];
|
x = x + a[key]; y = y + b[key];
|
||||||
});
|
});
|
||||||
@ -84,7 +84,7 @@ function getValue(lines, property, separator, trimmed) {
|
|||||||
|
|
||||||
function decodeEscapeSequence(str, base) {
|
function decodeEscapeSequence(str, base) {
|
||||||
base = base || 16;
|
base = base || 16;
|
||||||
return str.replace(/\\x([0-9A-Fa-f]{2})/g, function() {
|
return str.replace(/\\x([0-9A-Fa-f]{2})/g, function () {
|
||||||
return String.fromCharCode(parseInt(arguments[1], base));
|
return String.fromCharCode(parseInt(arguments[1], base));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -133,11 +133,11 @@ function getWmic() {
|
|||||||
return wmic;
|
return wmic;
|
||||||
}
|
}
|
||||||
|
|
||||||
function noop(){}
|
function noop() { }
|
||||||
|
|
||||||
exports.isFunction = isFunction;
|
exports.isFunction = isFunction;
|
||||||
exports.unique = unique;
|
exports.unique = unique;
|
||||||
exports.sortByKey= sortByKey;
|
exports.sortByKey = sortByKey;
|
||||||
exports.cores = cores;
|
exports.cores = cores;
|
||||||
exports.getValue = getValue;
|
exports.getValue = getValue;
|
||||||
exports.decodeEscapeSequence = decodeEscapeSequence;
|
exports.decodeEscapeSequence = decodeEscapeSequence;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user