mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-16 18:03:50 +00:00
Fix Windows binary path resolution for Bun compiled executable
This commit is contained in:
parent
468acdf0d6
commit
ccae220032
4 changed files with 91 additions and 79 deletions
|
|
@ -2,6 +2,10 @@
|
|||
|
||||
## [Unreleased]
|
||||
|
||||
### Fixed
|
||||
|
||||
- **Windows Binary Path Resolution**: Fixed Bun compiled binary on Windows failing to find `package.json` and other assets. The binary was incorrectly using the Bun runtime's virtual filesystem path (`B:\~BUN\`) instead of the actual executable location. Now uses `process.execPath` which correctly points to the compiled binary, and updated detection to check for `%7EBUN` (URL-encoded `~BUN`) in `import.meta.url`.
|
||||
|
||||
## [0.12.1] - 2025-12-02
|
||||
|
||||
### Changed
|
||||
|
|
|
|||
|
|
@ -7,9 +7,14 @@ const __dirname = dirname(__filename);
|
|||
|
||||
/**
|
||||
* Detect if we're running as a Bun compiled binary.
|
||||
* Bun binaries have import.meta.url starting with "file:///$bunfs/"
|
||||
* Bun binaries have import.meta.url containing "%7EBUN" (URL-encoded ~BUN virtual filesystem path)
|
||||
*/
|
||||
export const isBunBinary = import.meta.url.startsWith("file:///$bunfs/");
|
||||
export const isBunBinary = import.meta.url.includes("%7EBUN");
|
||||
|
||||
/**
|
||||
* Type definition for Bun global (only available when running via Bun)
|
||||
*/
|
||||
declare const Bun: { main: string } | undefined;
|
||||
|
||||
/**
|
||||
* Get the base directory for resolving package assets (themes, package.json, README.md, CHANGELOG.md).
|
||||
|
|
@ -19,7 +24,7 @@ export const isBunBinary = import.meta.url.startsWith("file:///$bunfs/");
|
|||
*/
|
||||
export function getPackageDir(): string {
|
||||
if (isBunBinary) {
|
||||
// Bun binary: resolve relative to the executable
|
||||
// Bun binary: process.execPath points to the compiled executable
|
||||
return dirname(process.execPath);
|
||||
}
|
||||
// Node.js: check if package.json exists in __dirname (dist/) or parent (src/ case)
|
||||
|
|
@ -32,7 +37,7 @@ export function getPackageDir(): string {
|
|||
|
||||
/**
|
||||
* Get path to the theme directory
|
||||
* - For Bun binary: dist/theme/ next to executable
|
||||
* - For Bun binary: theme/ next to executable
|
||||
* - For Node.js (dist/): dist/theme/
|
||||
* - For tsx (src/): src/theme/
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue