fix: parse file:// URLs correctly on Windows

On Windows, URL.pathname returns a path with an extra leading '/' (e.g.
'\C:\Users\whatever'). This causes problems when using Bun.spawn(). Fix
these problems by using the right method instead of URL.pathname.
This commit is contained in:
Matthew Glazar 2025-06-22 18:42:05 -04:00 committed by Dax Raad
parent 7fa2d78c3d
commit eb38d11a68

View file

@ -4,6 +4,7 @@ import { Server } from "./server/server"
import fs from "fs/promises"
import path from "path"
import { Share } from "./share/share"
import url from "node:url"
import { Global } from "./global"
import yargs from "yargs"
import { hideBin } from "yargs/helpers"
@ -63,7 +64,7 @@ const cli = yargs(hideBin(process.argv))
const server = Server.listen()
let cmd = ["go", "run", "./main.go"]
let cwd = new URL("../../tui/cmd/opencode", import.meta.url).pathname
let cwd = url.fileURLToPath(new URL("../../tui/cmd/opencode", import.meta.url))
if (Bun.embeddedFiles.length > 0) {
const blob = Bun.embeddedFiles[0] as File
const binary = path.join(Global.Path.cache, "tui", blob.name)