battery() fix designedCapacity (win, linux), fix catch error
This commit is contained in:
parent
a8cba81523
commit
2fd2454040
@ -77,6 +77,7 @@ For major (breaking) changes - **version 4, 3 and 2** - see end of page.
|
|||||||
|
|
||||||
| Version | Date | Comment |
|
| Version | Date | Comment |
|
||||||
| -------------- | -------------- | -------- |
|
| -------------- | -------------- | -------- |
|
||||||
|
| 5.7.8 | 2021-07-16 | `battery()` fix designedCapacity (win, linux), fix catch error |
|
||||||
| 5.7.7 | 2021-06-15 | `graphics()` improved detection screen resolution (macOS) |
|
| 5.7.7 | 2021-06-15 | `graphics()` improved detection screen resolution (macOS) |
|
||||||
| 5.7.6 | 2021-06-09 | `battery()` improved detection (additional batteries windows) |
|
| 5.7.6 | 2021-06-09 | `battery()` improved detection (additional batteries windows) |
|
||||||
| 5.7.5 | 2021-06-08 | `memLayout()` improved clock speed detection (windows) |
|
| 5.7.5 | 2021-06-08 | `memLayout()` improved clock speed detection (windows) |
|
||||||
@ -236,7 +237,7 @@ For major (breaking) changes - **version 4, 3 and 2** - see end of page.
|
|||||||
| 4.21.0 | 2020-01-27 | `npx` compatibility |
|
| 4.21.0 | 2020-01-27 | `npx` compatibility |
|
||||||
| 4.20.1 | 2020-01-26 | `battery()` code refactoring, cleanup, updated docs |
|
| 4.20.1 | 2020-01-26 | `battery()` code refactoring, cleanup, updated docs |
|
||||||
| 4.20.1 | 2020-01-26 | `battery()` code refactoring, cleanup, updated docs |
|
| 4.20.1 | 2020-01-26 | `battery()` code refactoring, cleanup, updated docs |
|
||||||
| 4.20.0 | 2020-01-25 | `battery()` added designcapacity, voltage, unit |
|
| 4.20.0 | 2020-01-25 | `battery()` added designCapacity, voltage, unit |
|
||||||
| 4.19.4 | 2020-01-24 | `mem()` prevent log messages, `memgetDefaultNetworkInterface()` catch errors |
|
| 4.19.4 | 2020-01-24 | `mem()` prevent log messages, `memgetDefaultNetworkInterface()` catch errors |
|
||||||
| 4.19.3 | 2020-01-24 | `memLayout()` bank info fix macOS |
|
| 4.19.3 | 2020-01-24 | `memLayout()` bank info fix macOS |
|
||||||
| 4.19.2 | 2020-01-19 | `cpu()` muli-processor fix windows |
|
| 4.19.2 | 2020-01-19 | `cpu()` muli-processor fix windows |
|
||||||
|
|||||||
@ -30,7 +30,7 @@
|
|||||||
[![Sponsoring][sponsor-badge]][sponsor-url]
|
[![Sponsoring][sponsor-badge]][sponsor-url]
|
||||||
[![MIT license][license-img]][license-url]
|
[![MIT license][license-img]][license-url]
|
||||||
|
|
||||||
This is amazing. Started as a small project just for myself, it now has > 10,000 lines of code, > 400 versions published, up to 3 mio downloads per month, > 30 mio downloads overall. Thank you to all who contributed to this project!
|
This is amazing. Started as a small project just for myself, it now has > 10,000 lines of code, > 400 versions published, up to 3 mio downloads per month, > 40 mio downloads overall. Thank you to all who contributed to this project!
|
||||||
|
|
||||||
## New Version 5.0
|
## New Version 5.0
|
||||||
|
|
||||||
|
|||||||
@ -56,6 +56,11 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<th scope="row">5.7.8</th>
|
||||||
|
<td>2021-07-16</td>
|
||||||
|
<td><span class="code">battery()</span> fix designedCapacity (win, linux), fix catch error</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">5.7.7</th>
|
<th scope="row">5.7.7</th>
|
||||||
<td>2021-06-15</td>
|
<td>2021-06-15</td>
|
||||||
|
|||||||
@ -170,7 +170,7 @@
|
|||||||
<img class="logo" src="assets/logo.png">
|
<img class="logo" src="assets/logo.png">
|
||||||
<div class="title">systeminformation</div>
|
<div class="title">systeminformation</div>
|
||||||
<div class="subtitle"><span id="typed"></span> </div>
|
<div class="subtitle"><span id="typed"></span> </div>
|
||||||
<div class="version">New Version: <span id="version">5.7.7</span></div>
|
<div class="version">New Version: <span id="version">5.7.8</span></div>
|
||||||
<button class="btn btn-light" onclick="location.href='https://github.com/sebhildebrandt/systeminformation'">View on Github <i class=" fab fa-github"></i></button>
|
<button class="btn btn-light" onclick="location.href='https://github.com/sebhildebrandt/systeminformation'">View on Github <i class=" fab fa-github"></i></button>
|
||||||
</div>
|
</div>
|
||||||
<div class="down">
|
<div class="down">
|
||||||
@ -211,7 +211,7 @@
|
|||||||
<div class="title">Downloads last month</div>
|
<div class="title">Downloads last month</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-xl-4 col-lg-4 col-md-4 col-12">
|
<div class="col-xl-4 col-lg-4 col-md-4 col-12">
|
||||||
<div class="numbers">424</div>
|
<div class="numbers">447</div>
|
||||||
<div class="title">Dependents</div>
|
<div class="title">Dependents</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -27,7 +27,7 @@ const _openbsd = (_platform === 'openbsd');
|
|||||||
const _netbsd = (_platform === 'netbsd');
|
const _netbsd = (_platform === 'netbsd');
|
||||||
const _sunos = (_platform === 'sunos');
|
const _sunos = (_platform === 'sunos');
|
||||||
|
|
||||||
function parseWinBatteryPart(lines, designCapacity, fullChargeCapacity) {
|
function parseWinBatteryPart(lines, designedCapacity, fullChargeCapacity) {
|
||||||
const result = {};
|
const result = {};
|
||||||
let status = util.getValue(lines, 'BatteryStatus', '=').trim();
|
let status = util.getValue(lines, 'BatteryStatus', '=').trim();
|
||||||
// 1 = "Discharging"
|
// 1 = "Discharging"
|
||||||
@ -46,7 +46,7 @@ function parseWinBatteryPart(lines, designCapacity, fullChargeCapacity) {
|
|||||||
result.status = statusValue;
|
result.status = statusValue;
|
||||||
result.hasBattery = true;
|
result.hasBattery = true;
|
||||||
result.maxCapacity = fullChargeCapacity || parseInt(util.getValue(lines, 'DesignCapacity', '=') || 0);
|
result.maxCapacity = fullChargeCapacity || parseInt(util.getValue(lines, 'DesignCapacity', '=') || 0);
|
||||||
result.designCapacity = parseInt(util.getValue(lines, 'DesignCapacity', '=') || designCapacity);
|
result.designedCapacity = parseInt(util.getValue(lines, 'DesignCapacity', '=') || designedCapacity);
|
||||||
result.voltage = parseInt(util.getValue(lines, 'DesignVoltage', '=') || 0) / 1000.0;
|
result.voltage = parseInt(util.getValue(lines, 'DesignVoltage', '=') || 0) / 1000.0;
|
||||||
result.capacityUnit = 'mWh';
|
result.capacityUnit = 'mWh';
|
||||||
result.percent = parseInt(util.getValue(lines, 'EstimatedChargeRemaining', '=') || 0);
|
result.percent = parseInt(util.getValue(lines, 'EstimatedChargeRemaining', '=') || 0);
|
||||||
@ -105,7 +105,7 @@ module.exports = function (callback) {
|
|||||||
result.currentCapacity = Math.round(parseInt('0' + util.getValue(lines, 'POWER_SUPPLY_CHARGE_NOW', '='), 10) / 1000.0 / (result.voltage || 1));
|
result.currentCapacity = Math.round(parseInt('0' + util.getValue(lines, 'POWER_SUPPLY_CHARGE_NOW', '='), 10) / 1000.0 / (result.voltage || 1));
|
||||||
if (!result.maxCapacity) {
|
if (!result.maxCapacity) {
|
||||||
result.maxCapacity = parseInt('0' + util.getValue(lines, 'POWER_SUPPLY_ENERGY_FULL', '='), 10) / 1000.0;
|
result.maxCapacity = parseInt('0' + util.getValue(lines, 'POWER_SUPPLY_ENERGY_FULL', '='), 10) / 1000.0;
|
||||||
result.designCapacity = parseInt('0' + util.getValue(lines, 'POWER_SUPPLY_ENERGY_FULL_DESIGN', '='), 10) / 1000.0 | result.maxCapacity;
|
result.designedCapacity = parseInt('0' + util.getValue(lines, 'POWER_SUPPLY_ENERGY_FULL_DESIGN', '='), 10) / 1000.0 | result.maxCapacity;
|
||||||
result.currentCapacity = parseInt('0' + util.getValue(lines, 'POWER_SUPPLY_ENERGY_NOW', '='), 10) / 1000.0;
|
result.currentCapacity = parseInt('0' + util.getValue(lines, 'POWER_SUPPLY_ENERGY_NOW', '='), 10) / 1000.0;
|
||||||
}
|
}
|
||||||
const percent = util.getValue(lines, 'POWER_SUPPLY_CAPACITY', '=');
|
const percent = util.getValue(lines, 'POWER_SUPPLY_CAPACITY', '=');
|
||||||
@ -236,13 +236,13 @@ module.exports = function (callback) {
|
|||||||
let additionalBatteries = [];
|
let additionalBatteries = [];
|
||||||
for (let i = 0; i < batteries.length; i++) {
|
for (let i = 0; i < batteries.length; i++) {
|
||||||
let lines = batteries[i];
|
let lines = batteries[i];
|
||||||
const designCapacity = designCapacities && designCapacities.length >= (i + 1) && designCapacities[i] ? util.toInt(designCapacities[i]) : 0;
|
const designedCapacity = designCapacities && designCapacities.length >= (i + 1) && designCapacities[i] ? util.toInt(designCapacities[i]) : 0;
|
||||||
const fullChargeCapacity = fullChargeCapacities && fullChargeCapacities.length >= (i + 1) && fullChargeCapacities[i] ? util.toInt(fullChargeCapacities[i]) : 0;
|
const fullChargeCapacity = fullChargeCapacities && fullChargeCapacities.length >= (i + 1) && fullChargeCapacities[i] ? util.toInt(fullChargeCapacities[i]) : 0;
|
||||||
const parsed = parseWinBatteryPart(lines, designCapacity, fullChargeCapacity);
|
const parsed = parseWinBatteryPart(lines, designedCapacity, fullChargeCapacity);
|
||||||
if (!first && parsed.status > 0 && parsed.status !== 10) {
|
if (!first && parsed.status > 0 && parsed.status !== 10) {
|
||||||
result.hasBattery = parsed.hasBattery;
|
result.hasBattery = parsed.hasBattery;
|
||||||
result.maxCapacity = parsed.maxCapacity;
|
result.maxCapacity = parsed.maxCapacity;
|
||||||
result.designCapacity = parsed.designCapacity;
|
result.designedCapacity = parsed.designedCapacity;
|
||||||
result.voltage = parsed.voltage;
|
result.voltage = parsed.voltage;
|
||||||
result.capacityUnit = parsed.capacityUnit;
|
result.capacityUnit = parsed.capacityUnit;
|
||||||
result.percent = parsed.percent;
|
result.percent = parsed.percent;
|
||||||
@ -256,7 +256,7 @@ module.exports = function (callback) {
|
|||||||
{
|
{
|
||||||
hasBattery: parsed.hasBattery,
|
hasBattery: parsed.hasBattery,
|
||||||
maxCapacity: parsed.maxCapacity,
|
maxCapacity: parsed.maxCapacity,
|
||||||
designCapacity: parsed.designCapacity,
|
designedCapacity: parsed.designedCapacity,
|
||||||
voltage: parsed.voltage,
|
voltage: parsed.voltage,
|
||||||
capacityUnit: parsed.capacityUnit,
|
capacityUnit: parsed.capacityUnit,
|
||||||
percent: parsed.percent,
|
percent: parsed.percent,
|
||||||
|
|||||||
14
lib/util.js
14
lib/util.js
@ -684,11 +684,15 @@ function getFilesInPath(source) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getFilesRecursively(source) {
|
function getFilesRecursively(source) {
|
||||||
let dirs = getDirectories(source);
|
try {
|
||||||
let files = dirs
|
let dirs = getDirectories(source);
|
||||||
.map(function (dir) { return getFilesRecursively(dir); })
|
let files = dirs
|
||||||
.reduce(function (a, b) { return a.concat(b); }, []);
|
.map(function (dir) { return getFilesRecursively(dir); })
|
||||||
return files.concat(getFiles(source));
|
.reduce(function (a, b) { return a.concat(b); }, []);
|
||||||
|
return files.concat(getFiles(source));
|
||||||
|
} catch (e) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fs.existsSync(source)) {
|
if (fs.existsSync(source)) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user