Fix Windows ESM import by using file URL
This commit is contained in:
@@ -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.
|
||||||
|
|||||||
Reference in New Issue
Block a user