feat: improve stdio test Windows compatibility and refactor command logic

This commit is contained in:
HoberMin 2025-04-08 09:27:19 +09:00 • committed by Felix Weinberger
commit a7dc125850
No known key found for this signature in database
2 changed files with 11 additions and 4 deletions

View file

@ -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);

View file

@ -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.
*/