Skip to content

Commit

Permalink
get() fixed issue boolean parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
sebhildebrandt committed Mar 3, 2021
1 parent 9ca44bb commit 80e20a8
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -77,6 +77,7 @@ For major (breaking) changes - **version 4, 3 and 2** - see end of page.

| Version | Date | Comment |
| -------------- | -------------- | -------- |
| 5.6.1 | 2021-03-03 | `get()` fixed issue boolean parameters |
| 5.6.0 | 2021-03-03 | `cpuTemperature()` added socket and chipset temp (linux) |
| 5.5.0 | 2021-02-25 | `dockerVolumes()` added |
| 5.4.0 | 2021-02-24 | `dockerImages()` added |
Expand Down
5 changes: 5 additions & 0 deletions docs/history.html
Expand Up @@ -56,6 +56,11 @@ <h3>Full version history</h3>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">5.6.1</th>
<td>2021-03-03</td>
<td><span class="code">get()</span> fixed issue boolean parameters</td>
</tr>
<tr>
<th scope="row">5.6.0</th>
<td>2021-03-03</td>
Expand Down
2 changes: 1 addition & 1 deletion docs/index.html
Expand Up @@ -170,7 +170,7 @@
<img class="logo" src="assets/logo.png">
<div class="title">systeminformation</div>
<div class="subtitle"><span id="typed"></span>&nbsp;</div>
<div class="version">New Version: <span id="version">5.6.0</span></div>
<div class="version">New Version: <span id="version">5.6.1</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>
</div>
<div class="down">
Expand Down
6 changes: 6 additions & 0 deletions lib/docker.js
Expand Up @@ -98,6 +98,9 @@ function dockerImages(all, callback) {
callback = all;
all = false;
}
if (typeof all === 'string' && all === 'true') {
all = true;
}
if (typeof all !== 'boolean' && all !== undefined) {
all = false;
}
Expand Down Expand Up @@ -218,6 +221,9 @@ function dockerContainers(all, callback) {
callback = all;
all = false;
}
if (typeof all === 'string' && all === 'true') {
all = true;
}
if (typeof all !== 'boolean' && all !== undefined) {
all = false;
}
Expand Down
17 changes: 11 additions & 6 deletions lib/index.js
Expand Up @@ -362,12 +362,17 @@ function get(valueObject, callback) {
// result is in an array, go through all elements of array and pick only the right ones
const partialArray = [];
data[i].forEach(element => {
const partialRes = {};
keys.forEach(k => {
if ({}.hasOwnProperty.call(element, k)) {
partialRes[k] = element[k];
}
});
let partialRes = {};
if (keys.length === 1 && (keys[0] === '*' || keys[0] === 'all')) {
partialRes = element;
} else {
keys.forEach(k => {
if ({}.hasOwnProperty.call(element, k)) {
partialRes[k] = element[k];
}
});
}
// if there is a filter, then just take those elements
if (filter && filterParts.length === 2) {
if ({}.hasOwnProperty.call(partialRes, filterParts[0].trim())) {
const val = partialRes[filterParts[0].trim()];
Expand Down
4 changes: 4 additions & 0 deletions lib/processes.js
Expand Up @@ -164,6 +164,10 @@ function services(srv, callback) {
}
}
}
if ((_darwin) && srvString === '*') { // service enumeration mnot yet suported on mac OS
if (callback) { callback(result); }
resolve(result);
}
let comm = (_darwin) ? 'ps -caxo pcpu,pmem,pid,command' : 'ps -axo pcpu,pmem,pid,command';
if (srvString !== '' && srvs.length > 0) {
exec(comm + ' | grep -v grep | grep -iE "' + srvString + '"', { maxBuffer: 1024 * 20000 }, function (error, stdout) { // lgtm [js/shell-command-constructed-from-input]
Expand Down

0 comments on commit 80e20a8

Please sign in to comment.