Skip to content

Commit 67f3536

Browse files
committed
Make cli output awaitable to prevent truncating the result
1 parent 7fc4e87 commit 67f3536

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

cli/src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
} from "./client/index.js";
2020
import { handleError } from "./error-handler.js";
2121
import { createTransport, TransportOptions } from "./transport.js";
22+
import { awaitableLog } from "./utils/awaitable-log.js";
2223

2324
type Args = {
2425
target: string[];
@@ -150,7 +151,7 @@ async function callMethod(args: Args): Promise<void> {
150151
);
151152
}
152153

153-
console.log(JSON.stringify(result, null, 2));
154+
await awaitableLog(JSON.stringify(result, null, 2));
154155
} finally {
155156
try {
156157
await disconnect(transport);

cli/src/utils/awaitable-log.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export function awaitableLog(logValue: string): Promise<void> {
2+
return new Promise<void>((resolve) => {
3+
process.stdout.write(logValue, () => {
4+
resolve();
5+
});
6+
});
7+
}

0 commit comments

Comments
 (0)