Fix varListChildren() when there are no children

Return [] instead of throwing exception.
This commit is contained in:
gentoo90 2017-06-10 15:01:21 +03:00
commit c313af85b2

View file

@ -679,7 +679,7 @@ export class MI2 extends EventEmitter implements IBackend {
this.log("stderr", "varListChildren");
//TODO: add `from` and `to` arguments
const res = await this.sendCommand(`var-list-children --all-values ${name}`);
const children = res.result("children");
const children = res.result("children") || [];
let omg: VariableObject[] = children.map(child => new VariableObject(child[1]));
return omg;
}