bug fix (battery - windows)
This commit is contained in:
parent
ed3763cba9
commit
ccd8a17fd1
@ -98,6 +98,7 @@ Other changes
|
||||
|
||||
| Version | Date | Comment |
|
||||
| -------------- | -------------- | -------- |
|
||||
| 3.23.2 | 2017-06-23 | bug fix `battery` (windows) |
|
||||
| 3.23.1 | 2017-06-22 | updated docs |
|
||||
| 3.23.0 | 2017-06-22 | added `memLayout`, `diskLayout`, extended windows support (`inetChecksite`)|
|
||||
| 3.22.0 | 2017-06-19 | extended windows support (`users`, `inetLatency`) |
|
||||
|
||||
@ -10,7 +10,7 @@ Simple system and OS information library for [node.js][nodejs-url]
|
||||
|
||||
## Quick Start
|
||||
|
||||
Collection of 30+ functions to retrieve detailed hardware, system and OS information (Linux, OSX and now partial Windows support)
|
||||
Collection of 35+ functions to retrieve detailed hardware, system and OS information (Linux, OSX and partial Windows support)
|
||||
|
||||
### Installation
|
||||
|
||||
@ -110,7 +110,7 @@ I also created a nice little command line tool called [mmon][mmon-github-url] (
|
||||
| | serial | X | X | X | serial number |
|
||||
| | uuid | X | X | X | UUID |
|
||||
|
||||
#### 3. CPU, Memory, Battery, Graphics
|
||||
#### 3. CPU, Memory, Disks, Battery, Graphics
|
||||
|
||||
| Function | Result object | Linux | OSX | Win | Comments |
|
||||
| --------------- | ----- | ----- | ---- | ------- | -------- |
|
||||
|
||||
@ -117,15 +117,18 @@ module.exports = function (callback) {
|
||||
}
|
||||
if (_windows) {
|
||||
exec("WMIC Path Win32_Battery Get BatteryStatus, DesignCapacity, EstimatedChargeRemaining /value", function (error, stdout) {
|
||||
if (!error) {
|
||||
if (stdout) {
|
||||
let lines = stdout.split('\r\n');
|
||||
let status = parseInt(getValue(lines, 'BatteryStatus', '=') || '2');
|
||||
let status = getValue(lines, 'BatteryStatus', '=').trim();
|
||||
if (status) {
|
||||
status = parseInt(status || '2');
|
||||
result.hasbattery = true;
|
||||
result.maxcapacity = parseInt(getValue(lines, 'DesignCapacity', '=') || 0);
|
||||
result.percent = parseInt(getValue(lines, 'EstimatedChargeRemaining', '=') || 0);
|
||||
result.currentcapacity = parseInt(result.maxcapacity * result.percent / 100);
|
||||
result.ischarging = (status >= 6 && status <= 9) || (!(status === 3) && !(status === 1) && result.percent < 100);
|
||||
}
|
||||
}
|
||||
if (callback) { callback(result) }
|
||||
resolve(result);
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user