Fix Windows ESM import by using file URL

This commit is contained in:
SenaxZz
2026-04-01 13:53:36 +02:00
committed by GitHub
parent c1317ef544
commit 2ee43e010b

View File

@@ -9,14 +9,13 @@
import { existsSync } from 'fs' import { existsSync } from 'fs'
import { join, dirname } from 'path' import { join, dirname } from 'path'
import { fileURLToPath } from 'url' import { fileURLToPath, pathToFileURL } from 'url'
import { getDistImportSpecifier } from './import-specifier.mjs'
const __dirname = dirname(fileURLToPath(import.meta.url)) const __dirname = dirname(fileURLToPath(import.meta.url))
const distPath = join(__dirname, '..', 'dist', 'cli.mjs') const distPath = join(__dirname, '..', 'dist', 'cli.mjs')
if (existsSync(distPath)) { if (existsSync(distPath)) {
await import(getDistImportSpecifier(__dirname)) await import(pathToFileURL(distPath).href)
} else { } else {
console.error(` console.error(`
openclaude: dist/cli.mjs not found. openclaude: dist/cli.mjs not found.