From a74b09d2c151ac08e3271275876227b5b8e1de01 Mon Sep 17 00:00:00 2001 From: pyoor Date: Mon, 27 Aug 2018 19:00:00 -0400 Subject: [PATCH] Wrap all runner output in try/catch --- lib/utils/script.js | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/lib/utils/script.js b/lib/utils/script.js index 67d95dc..f955c6d 100644 --- a/lib/utils/script.js +++ b/lib/utils/script.js @@ -92,20 +92,18 @@ class script extends utils { cmds = (Array.isArray(cmds)) ? cmds : [cmds] cmds = cmds.filter((i) => i !== undefined) if (cmds.length) { - if (random.chance(50)) { - // Wrap each command in try/catch for use in setInterval, setTimeout, repeater - switch (random.number(3)) { - case 0: - return `setInterval(function () { ${utils.script.safely(cmds)} }, ${random.range(100, 400)} )` - case 1: - return `setTimeout(function () { ${utils.script.safely(cmds)} }, ${random.range(100, 400)} )` - case 2: - let n = random.number(random.number(30)) - return `for (let i = 0; i < ${n}; i++) { ${utils.script.safely(cmds)} }` - } + // Wrap each command in try/catch for use in setInterval, setTimeout, repeater + switch (random.number(50)) { + case 0: + return script.safely(`setInterval(function () { ${script.safely(cmds)} }, ${random.range(100, 400)} )`) + case 1: + return script.safely(`setTimeout(function () { ${script.safely(cmds)} }, ${random.range(100, 400)} )`) + case 2: + let n = random.number(random.number(30)) + return script.safely(`for (let i = 0; i < ${n}; i++) { ${script.safely(cmds)} }`) + default: + return script.safely(cmds) } - - return utils.script.safely(cmds) } }