From 67f35363d8e130b57bbad7e1554f375c86e15c4c Mon Sep 17 00:00:00 2001 From: Chris Griffing Date: Tue, 26 Aug 2025 16:14:44 -0700 Subject: [PATCH] Make cli output awaitable to prevent truncating the result --- cli/src/index.ts | 3 ++- cli/src/utils/awaitable-log.ts | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 cli/src/utils/awaitable-log.ts diff --git a/cli/src/index.ts b/cli/src/index.ts index 2b0c4f53dd..a7e21c76de 100644 --- a/cli/src/index.ts +++ b/cli/src/index.ts @@ -19,6 +19,7 @@ import { } from "./client/index.js"; import { handleError } from "./error-handler.js"; import { createTransport, TransportOptions } from "./transport.js"; +import { awaitableLog } from "./utils/awaitable-log.js"; type Args = { target: string[]; @@ -150,7 +151,7 @@ async function callMethod(args: Args): Promise { ); } - console.log(JSON.stringify(result, null, 2)); + await awaitableLog(JSON.stringify(result, null, 2)); } finally { try { await disconnect(transport); diff --git a/cli/src/utils/awaitable-log.ts b/cli/src/utils/awaitable-log.ts new file mode 100644 index 0000000000..144f011234 --- /dev/null +++ b/cli/src/utils/awaitable-log.ts @@ -0,0 +1,7 @@ +export function awaitableLog(logValue: string): Promise { + return new Promise((resolve) => { + process.stdout.write(logValue, () => { + resolve(); + }); + }); +}