Skip to content

Commit 39e7fc0

Browse files
committed
fix(realpathsync): use realpathSync
1 parent 02bf611 commit 39e7fc0

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mock-mcp",
3-
"version": "0.2.2",
3+
"version": "0.2.3",
44
"description": "An MCP server enabling LLMs to write integration tests through live test environment interaction",
55
"main": "./dist/connect.cjs",
66
"type": "module",

src/index.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env node
22
import { pathToFileURL } from "node:url";
3+
import { realpathSync } from "node:fs";
34
import process from "node:process";
45
import {
56
TestMockMCPServer,
@@ -14,8 +15,6 @@ import { connect, type ConnectOptions } from "./client/connect.js";
1415

1516
const DEFAULT_PORT = 3002;
1617

17-
console.error('mock-mcp running');
18-
1918
async function runCli() {
2019
const cliArgs = process.argv.slice(2);
2120
let port = Number.parseInt(process.env.MCP_SERVER_PORT ?? "", 10);
@@ -61,7 +60,11 @@ const isCliExecution = (() => {
6160
return false;
6261
}
6362

64-
return import.meta.url === pathToFileURL(process.argv[1]!).href;
63+
// Resolve symlinks to ensure proper comparison between import.meta.url and argv[1]
64+
// This is necessary because import.meta.url contains the real path,
65+
// while process.argv[1] may contain symlinks (e.g., /tmp vs /private/tmp on macOS)
66+
const scriptPath = realpathSync(process.argv[1]!);
67+
return import.meta.url === pathToFileURL(scriptPath).href;
6568
})();
6669

6770
if (isCliExecution) {

0 commit comments

Comments
 (0)