From a7dc1258501cde8cc4a20fb7415c82b18e3bb78b Mon Sep 17 00:00:00 2001 From: HoberMin <102784200+HoberMin@users.noreply.github.com> Date: Tue, 8 Apr 2025 09:27:19 +0900 Subject: [PATCH] feat: improve stdio test Windows compatibility and refactor command logic --- src/client/stdio.test.ts | 6 ++---- src/client/stdio.ts | 9 +++++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/client/stdio.test.ts b/src/client/stdio.test.ts index b2132446..8c3786eb 100644 --- a/src/client/stdio.test.ts +++ b/src/client/stdio.test.ts @@ -1,9 +1,7 @@ import { JSONRPCMessage } from "../types.js"; -import { StdioClientTransport, StdioServerParameters } from "./stdio.js"; +import { StdioClientTransport, getDefaultServerParameters } from "./stdio.js"; -const serverParameters: StdioServerParameters = { - command: "/usr/bin/tee", -}; +const serverParameters = getDefaultServerParameters(); test("should start then close cleanly", async () => { const client = new StdioClientTransport(serverParameters); diff --git a/src/client/stdio.ts b/src/client/stdio.ts index 62292ce1..a34e8f19 100644 --- a/src/client/stdio.ts +++ b/src/client/stdio.ts @@ -39,6 +39,15 @@ export type StdioServerParameters = { cwd?: string; }; +// Configure default server parameters based on OS +// Uses 'more' command for Windows and 'tee' command for Unix/Linux +export const getDefaultServerParameters = (): StdioServerParameters => { + if (process.platform === "win32") { + return { command: "more" }; + } + return { command: "/usr/bin/tee" }; +}; + /** * Environment variables to inherit by default, if an environment is not explicitly given. */