Skip to content

Commit d0e9fc4

Browse files
committed
Refactor directory path resolution in pyright-bridge.ts to use fileURLToPath for improved compatibility with ES modules.
1 parent 6b1dd9c commit d0e9fc4

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

pyright-bridge.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ import { WebSocketServer } from 'ws'
33
import { toSocket, WebSocketMessageReader, WebSocketMessageWriter } from 'vscode-ws-jsonrpc'
44
import { StreamMessageReader, StreamMessageWriter } from 'vscode-jsonrpc/node.js'
55
import { readFileSync, writeFileSync, existsSync } from 'fs'
6-
import path, { join } from 'path'
6+
import path, { dirname, join } from 'path'
7+
import { fileURLToPath } from 'url'
8+
79
import 'dotenv/config'
810

9-
// Get the directory where the binary is executed from
10-
// Use process.cwd() for pkg compatibility (node_modules is external)
11-
const __dirname = process.cwd()
11+
// Get the directory where bundle.js is located (not cwd)
12+
const __filename = fileURLToPath(import.meta.url)
13+
const __dirname = dirname(__filename)
1214

1315
// Parse command-line arguments
1416
function parseArgs() {

0 commit comments

Comments
 (0)