Commit e03abc8
fix(mcp-server): resolve __dirname ReferenceError in ESM test context
In vitest (which runs TypeScript source as ESM), the CJS module-level
__dirname variable is undefined. The bare reference threw a ReferenceError
at module load time, failing all knowledge.test.ts tests.
Use a try/catch so the ReferenceError is caught and the fallback derives
the bundled knowledge path from process.cwd() (repo root in CI). The
compiled esbuild CJS output is unaffected — __dirname remains valid there.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent 2e705c4 commit e03abc8
1 file changed
Lines changed: 11 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
18 | 28 | | |
19 | | - | |
| 29 | + | |
20 | 30 | | |
21 | 31 | | |
22 | 32 | | |
| |||
0 commit comments