From 38f8ff058945f603c343577bf1d28fca38091005 Mon Sep 17 00:00:00 2001 From: Nbiba Bedis Date: Sun, 24 Mar 2024 09:50:47 +0100 Subject: [PATCH] more complex heuristic --- tests/deno_bot_test.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/deno_bot_test.ts b/tests/deno_bot_test.ts index 5215b53..e351be9 100755 --- a/tests/deno_bot_test.ts +++ b/tests/deno_bot_test.ts @@ -29,17 +29,29 @@ if (import.meta.main) { // TODO let lastResult = ""; let idx = 0; + let start = 0; while (true) { let { data: output, done } = await pty.read(); if (done) break; output = stripAnsiCode(output).trim(); if (output && output !== "In:") lastResult = output; - if (!output && lastResult) { + if (output && start === 0) { + start = 1; + } + if (!output && start === 1) { + start = 2; + } + if (output && start === 2) { + start = 3; + } + + if (start === 3 && !output && lastResult) { idx++; } else { idx = 0; } + if (idx === 5) { const result = lastResult.replace(/^Out:/, "").trim(); return result;