diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7aa5026..2b6de3b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -77,6 +77,7 @@ For major (breaking) changes - **version 4, 3 and 2** - see end of page.
| 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.6 | 2021-06-09 | `battery()` improved detection (additional batteries 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.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.3 | 2020-01-24 | `memLayout()` bank info fix macOS |
| 4.19.2 | 2020-01-19 | `cpu()` muli-processor fix windows |
diff --git a/README.md b/README.md
index c3f2d50..a287f2d 100644
--- a/README.md
+++ b/README.md
@@ -30,7 +30,7 @@
[![Sponsoring][sponsor-badge]][sponsor-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
diff --git a/docs/history.html b/docs/history.html
index 0359bfe..5281440 100644
--- a/docs/history.html
+++ b/docs/history.html
@@ -56,6 +56,11 @@
+
+ | 5.7.8 |
+ 2021-07-16 |
+ battery() fix designedCapacity (win, linux), fix catch error |
+
| 5.7.7 |
2021-06-15 |
diff --git a/docs/index.html b/docs/index.html
index 6abd66f..e3e4c22 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -170,7 +170,7 @@
systeminformation
- New Version: 5.7.7
+ New Version: 5.7.8
@@ -211,7 +211,7 @@
Downloads last month
diff --git a/lib/battery.js b/lib/battery.js
index 3e61782..6bd5eb6 100644
--- a/lib/battery.js
+++ b/lib/battery.js
@@ -27,7 +27,7 @@ const _openbsd = (_platform === 'openbsd');
const _netbsd = (_platform === 'netbsd');
const _sunos = (_platform === 'sunos');
-function parseWinBatteryPart(lines, designCapacity, fullChargeCapacity) {
+function parseWinBatteryPart(lines, designedCapacity, fullChargeCapacity) {
const result = {};
let status = util.getValue(lines, 'BatteryStatus', '=').trim();
// 1 = "Discharging"
@@ -46,7 +46,7 @@ function parseWinBatteryPart(lines, designCapacity, fullChargeCapacity) {
result.status = statusValue;
result.hasBattery = true;
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.capacityUnit = 'mWh';
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));
if (!result.maxCapacity) {
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;
}
const percent = util.getValue(lines, 'POWER_SUPPLY_CAPACITY', '=');
@@ -236,13 +236,13 @@ module.exports = function (callback) {
let additionalBatteries = [];
for (let i = 0; i < batteries.length; 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 parsed = parseWinBatteryPart(lines, designCapacity, fullChargeCapacity);
+ const parsed = parseWinBatteryPart(lines, designedCapacity, fullChargeCapacity);
if (!first && parsed.status > 0 && parsed.status !== 10) {
result.hasBattery = parsed.hasBattery;
result.maxCapacity = parsed.maxCapacity;
- result.designCapacity = parsed.designCapacity;
+ result.designedCapacity = parsed.designedCapacity;
result.voltage = parsed.voltage;
result.capacityUnit = parsed.capacityUnit;
result.percent = parsed.percent;
@@ -256,7 +256,7 @@ module.exports = function (callback) {
{
hasBattery: parsed.hasBattery,
maxCapacity: parsed.maxCapacity,
- designCapacity: parsed.designCapacity,
+ designedCapacity: parsed.designedCapacity,
voltage: parsed.voltage,
capacityUnit: parsed.capacityUnit,
percent: parsed.percent,
diff --git a/lib/util.js b/lib/util.js
index b4c1029..32936f3 100644
--- a/lib/util.js
+++ b/lib/util.js
@@ -684,11 +684,15 @@ function getFilesInPath(source) {
}
function getFilesRecursively(source) {
- let dirs = getDirectories(source);
- let files = dirs
- .map(function (dir) { return getFilesRecursively(dir); })
- .reduce(function (a, b) { return a.concat(b); }, []);
- return files.concat(getFiles(source));
+ try {
+ let dirs = getDirectories(source);
+ let files = dirs
+ .map(function (dir) { return getFilesRecursively(dir); })
+ .reduce(function (a, b) { return a.concat(b); }, []);
+ return files.concat(getFiles(source));
+ } catch (e) {
+ return [];
+ }
}
if (fs.existsSync(source)) {