get() fixed issue boolean parameters

This commit is contained in:
Sebastian Hildebrandt
2021-03-03 19:49:53 +01:00
parent 9ca44bb211
commit 80e20a8268
6 changed files with 28 additions and 7 deletions
+6
View File
@@ -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;
}
@@ -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;
}
+11 -6
View File
@@ -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()];
+4
View File
@@ -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]