get() fixed issue boolean parameters
This commit is contained in:
@@ -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
@@ -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()];
|
||||
|
||||
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user