message: Added breaking on a potential infinite loop with optional override. Added a predefined expression for the times command so just a number needs to be provided as the target. Also cleaned up the code styling a bit so it's a little easier to read.
diff: @@ -33,8 +33,13 @@ export class CommandNode {
  }
  execute(extCommand) {
  + this.timesVisited++;
  + this.checkRetryLimit();
  if (extCommand.isExtCommand(this.command.command)) {
  - return extCommand[extCommand.name(this.command.command)](xlateArgument(this.command.target), xlateArgument(this.command.value)).then(() => {
  + return extCommand[extCommand.name(this.command.command)](
  + xlateArgument(this.command.target),
  + xlateArgument(this.command.value))
  + .then(() => {
  return {
  next: this.next
  };
  @@ -46,7 +51,12 @@ export class CommandNode {
  };
  });
  } else {
  - return extCommand.sendMessage(this.command.command, this.command.target, this.command.value, extCommand.isWindowMethodCommand(this.command.command)).then((result) => {
  + return extCommand.sendMessage(
  + this.command.command,
  + this.command.target,
  + this.command.value,
  + extCommand.isWindowMethodCommand(this.command.command))
  + .then((result) => {
  if (result.result === "success") {
  return {
  result: "success",
  @@ -60,7 +70,16 @@ export class CommandNode {
  }
  evaluate(extCommand) {
  - return extCommand.sendMessage("evaluateConditional", this.command.target, "", false).then((result) => {
  + let expression = this.command.target;
  + if (this.command.command === "times") {
  + if (isNaN(this.command.target)) {
  + throw Error("Number not provided in target input field of the times command.");
  + }
  + expression = `${this.timesVisited} <= ${this.command.target}`;
  + }
  + return extCommand.sendMessage(
  + "evaluateConditional", expression, "", false)
  + .then((result) => {
  if (result.value) {
  return {
  next: this.right
  @@ -72,4 +91,14 @@ export class CommandNode {
  }
  });
  }
  +
  + checkRetryLimit() {
  + let limit = 1000;
  + if (this.command.value && !isNaN(this.command.value)) {
  + limit = this.command.value;
  + }
  + if (this.timesVisited > limit) {
  + throw new Error(`Max command retry limit (${limit}) exceeded. Potential infinite loop detected. To override the limit, specify an alternate number in the value input field of the looping command.`);
  + }
  + }
  }
  