(dirname: string)
| 8 | * @param dirname - The __dirname equivalent for the calling module |
| 9 | */ |
| 10 | export function getDefaultExtensionPath(dirname: string): string { |
| 11 | // Check for environment variable first (set by install script) |
| 12 | if (process.env.ROO_EXTENSION_PATH) { |
| 13 | const envPath = process.env.ROO_EXTENSION_PATH |
| 14 | |
| 15 | if (fs.existsSync(path.join(envPath, "extension.js"))) { |
| 16 | return envPath |
| 17 | } |
| 18 | } |
| 19 | |
| 20 | // Find the CLI package root (apps/cli) by walking up to the nearest package.json. |
| 21 | // This works whether called from dist/ (bundled) or src/commands/cli/ (tsx dev). |
| 22 | let packageRoot = dirname |
| 23 | |
| 24 | while (packageRoot !== path.dirname(packageRoot)) { |
| 25 | if (fs.existsSync(path.join(packageRoot, "package.json"))) { |
| 26 | break |
| 27 | } |
| 28 | |
| 29 | packageRoot = path.dirname(packageRoot) |
| 30 | } |
| 31 | |
| 32 | // The extension is at ../../src/dist relative to apps/cli (monorepo/src/dist) |
| 33 | const monorepoPath = path.resolve(packageRoot, "../../src/dist") |
| 34 | |
| 35 | if (fs.existsSync(path.join(monorepoPath, "extension.js"))) { |
| 36 | return monorepoPath |
| 37 | } |
| 38 | |
| 39 | // Fallback: when installed via curl script, extension is at apps/cli/extension |
| 40 | const packagePath = path.resolve(packageRoot, "extension") |
| 41 | return packagePath |
| 42 | } |
no outgoing calls
no test coverage detected