豆豆友情提示:这是一个非官方 GitHub 代理镜像,主要用于网络测试或访问加速。请勿在此进行登录、注册或处理任何敏感信息。进行这些操作请务必访问官方网站 github.com。 Raw 内容也通过此代理提供。
Skip to content

Commit a106170

Browse files
authored
chore: make eval scripts cross-platform compatible (Windows) (#1030)
Fixes #1029 ## Summary - Use `pathToFileURL()` from `node:url` for dynamic imports in `eval_gemini.ts` to fix `ERR_UNSUPPORTED_ESM_URL_SCHEME` on Windows - converts absolute paths like `D:\projects\...\console_test.ts` to proper `file:///D:/projects/.../console_test.ts` URLs that the Node.js ESM loader accepts on all platforms - Move `CHROME_DEVTOOLS_MCP_NO_USAGE_STATISTICS=true` from Unix-only shell env var prefix in `package.json` into `eval_gemini.ts` code, matching the pattern already used in `scripts/test.mjs` - Add `.gitattributes` with `* text=auto eol=lf` to enforce LF line endings on checkout - Windows contributors cloning the repo would otherwise get CRLF endings, which conflicts with the project's Prettier `endOfLine: 'lf'` config and causes spurious diffs or formatting failures
1 parent b5d01b5 commit a106170

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto eol=lf

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"prepare": "node --experimental-strip-types scripts/prepare.ts",
2424
"verify-server-json-version": "node --experimental-strip-types scripts/verify-server-json-version.ts",
2525
"verify-npm-package": "node scripts/verify-npm-package.mjs",
26-
"eval": "npm run build && CHROME_DEVTOOLS_MCP_NO_USAGE_STATISTICS=true node --experimental-strip-types scripts/eval_gemini.ts",
26+
"eval": "npm run build && node --experimental-strip-types scripts/eval_gemini.ts",
2727
"count-tokens": "node --experimental-strip-types scripts/count_tokens.ts"
2828
},
2929
"files": [

scripts/eval_gemini.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import fs from 'node:fs';
88
import path from 'node:path';
9+
import {pathToFileURL} from 'node:url';
910
import {parseArgs} from 'node:util';
1011

1112
import {GoogleGenAI, mcpToTool} from '@google/genai';
@@ -35,7 +36,7 @@ export interface TestScenario {
3536
}
3637

3738
async function loadScenario(scenarioPath: string): Promise<TestScenario> {
38-
const module = await import(scenarioPath);
39+
const module = await import(pathToFileURL(scenarioPath).href);
3940
if (!module.scenario) {
4041
throw new Error(
4142
`Scenario file ${scenarioPath} does not export a 'scenario' object.`,
@@ -110,6 +111,7 @@ async function runSingleScenario(
110111
env[key] = value;
111112
}
112113
});
114+
env['CHROME_DEVTOOLS_MCP_NO_USAGE_STATISTICS'] = 'true';
113115

114116
const args = [serverPath];
115117
if (!debug) {

0 commit comments

Comments
 (0)