fix: resolve version detection for npm global installations (#1194)
When oh-my-opencode is installed via npm global install and run as a compiled binary, import.meta.url returns a virtual bun path ($bunfs) instead of the actual filesystem path. This caused getCachedVersion() to return null, resulting in 'unknown' version display. Add fallback using process.execPath which correctly points to the actual binary location, allowing us to walk up and find the package.json. Fixes #1182
This commit is contained in:
parent
995b7751af
commit
28a0dd06c7
@ -170,6 +170,20 @@ export function getCachedVersion(): string | null {
|
||||
log("[auto-update-checker] Failed to resolve version from current directory:", err)
|
||||
}
|
||||
|
||||
// Fallback for compiled binaries (npm global install)
|
||||
// process.execPath points to the actual binary location
|
||||
try {
|
||||
const execDir = path.dirname(fs.realpathSync(process.execPath))
|
||||
const pkgPath = findPackageJsonUp(execDir)
|
||||
if (pkgPath) {
|
||||
const content = fs.readFileSync(pkgPath, "utf-8")
|
||||
const pkg = JSON.parse(content) as PackageJson
|
||||
if (pkg.version) return pkg.version
|
||||
}
|
||||
} catch (err) {
|
||||
log("[auto-update-checker] Failed to resolve version from execPath:", err)
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user