Skip to content

Commit a7dc125

Browse files
HoberMinfelixweinberger
authored andcommitted
feat: improve stdio test Windows compatibility and refactor command logic
1 parent 60310e9 commit a7dc125

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/client/stdio.test.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import { JSONRPCMessage } from "../types.js";
2-
import { StdioClientTransport, StdioServerParameters } from "./stdio.js";
2+
import { StdioClientTransport, getDefaultServerParameters } from "./stdio.js";
33

4-
const serverParameters: StdioServerParameters = {
5-
command: "/usr/bin/tee",
6-
};
4+
const serverParameters = getDefaultServerParameters();
75

86
test("should start then close cleanly", async () => {
97
const client = new StdioClientTransport(serverParameters);

src/client/stdio.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,15 @@ export type StdioServerParameters = {
3939
cwd?: string;
4040
};
4141

42+
// Configure default server parameters based on OS
43+
// Uses 'more' command for Windows and 'tee' command for Unix/Linux
44+
export const getDefaultServerParameters = (): StdioServerParameters => {
45+
if (process.platform === "win32") {
46+
return { command: "more" };
47+
}
48+
return { command: "/usr/bin/tee" };
49+
};
50+
4251
/**
4352
* Environment variables to inherit by default, if an environment is not explicitly given.
4453
*/

0 commit comments

Comments
 (0)