From 13e0f71ec4c3e765ecff3a2e6d1ed900ea0b69f9 Mon Sep 17 00:00:00 2001 From: Nbiba Bedis Date: Sat, 28 Oct 2023 09:27:11 +0100 Subject: [PATCH] update deno bot test --- tests/deno_bot_test.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/tests/deno_bot_test.ts b/tests/deno_bot_test.ts index 999bb6f..ee53178 100755 --- a/tests/deno_bot_test.ts +++ b/tests/deno_bot_test.ts @@ -1,22 +1,25 @@ #!/usr/bin/env -S deno run --unstable --allow-all -import { Pty } from "https://deno.land/x/deno_pty_ffi@0.9.0/mod.ts"; -import { stripColor } from "https://deno.land/std@0.200.0/fmt/colors.ts"; +import { Pty } from "https://deno.land/x/deno_pty_ffi@0.16.0/mod.ts"; +import { stripAnsiCode } from "https://deno.land/std@0.204.0/fmt/colors.ts"; import { assertEquals, assertMatch, -} from "https://deno.land/std@0.184.0/testing/asserts.ts"; +} from "https://deno.land/std@0.204.0/assert/mod.ts"; const ENCODER = new TextEncoder(); if (import.meta.main) { - const pty = await Pty.create({ + const pty = new Pty({ cmd: "cargo", args: ["run", "--", "--default-config"], env: [["NO_COLOR", "1"]], }); while (true) { - const input = await pty.read().then(stripColor); + let input = await pty.read(); + if (input === undefined) break; + input = stripAnsiCode(input); + if (input.includes("In:")) break; await sleep(100); } @@ -37,7 +40,9 @@ if (import.meta.main) { let out = ""; let end_detect = 0; while (true) { - const o = await pty.read().then(stripColor); + let o = await pty.read(); + if (o === undefined) break; + o = stripAnsiCode(o); if (!o.startsWith("In:")) { end_detect += 1; out += o;