mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-21 04:00:10 +00:00
Fix path resolution in config.ts after file reorganization
This commit is contained in:
parent
83a6c26969
commit
6adfb64279
1 changed files with 15 additions and 9 deletions
|
|
@ -32,26 +32,32 @@ export function getPackageDir(): string {
|
||||||
// Bun binary: process.execPath points to the compiled executable
|
// Bun binary: process.execPath points to the compiled executable
|
||||||
return dirname(process.execPath);
|
return dirname(process.execPath);
|
||||||
}
|
}
|
||||||
// Node.js: check if package.json exists in __dirname (dist/) or parent (src/ case)
|
// Node.js: walk up from __dirname until we find package.json
|
||||||
if (existsSync(join(__dirname, "package.json"))) {
|
let dir = __dirname;
|
||||||
return __dirname;
|
while (dir !== dirname(dir)) {
|
||||||
|
if (existsSync(join(dir, "package.json"))) {
|
||||||
|
return dir;
|
||||||
}
|
}
|
||||||
// Running from src/ via tsx - go up one level to package root
|
dir = dirname(dir);
|
||||||
return dirname(__dirname);
|
}
|
||||||
|
// Fallback (shouldn't happen)
|
||||||
|
return __dirname;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get path to built-in themes directory (shipped with package)
|
* Get path to built-in themes directory (shipped with package)
|
||||||
* - For Bun binary: theme/ next to executable
|
* - For Bun binary: theme/ next to executable
|
||||||
* - For Node.js (dist/): dist/theme/
|
* - For Node.js (dist/): dist/modes/interactive/theme/
|
||||||
* - For tsx (src/): src/theme/
|
* - For tsx (src/): src/modes/interactive/theme/
|
||||||
*/
|
*/
|
||||||
export function getThemesDir(): string {
|
export function getThemesDir(): string {
|
||||||
if (isBunBinary) {
|
if (isBunBinary) {
|
||||||
return join(dirname(process.execPath), "theme");
|
return join(dirname(process.execPath), "theme");
|
||||||
}
|
}
|
||||||
// __dirname is either dist/ or src/ - theme is always a subdirectory
|
// Theme is in modes/interactive/theme/ relative to src/ or dist/
|
||||||
return join(__dirname, "theme");
|
const packageDir = getPackageDir();
|
||||||
|
const srcOrDist = existsSync(join(packageDir, "src")) ? "src" : "dist";
|
||||||
|
return join(packageDir, srcOrDist, "modes", "interactive", "theme");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get path to package.json */
|
/** Get path to package.json */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue