This commit is contained in:
decolua
2026-04-06 17:32:44 +07:00
parent 7db4b9834e
commit 307be3b63d
18 changed files with 406 additions and 179 deletions
@@ -12,14 +12,23 @@ const execAsync = promisify(exec);
const getConfigDir = () => path.join(os.homedir(), ".config", "opencode");
const getConfigPath = () => path.join(getConfigDir(), "opencode.json");
// Check if opencode CLI is installed (via which/where or config file exists)
const checkOpenCodeInstalled = async () => {
try {
const isWindows = os.platform() === "win32";
const command = isWindows ? "where opencode" : "command -v opencode";
await execAsync(command, { windowsHide: true });
const command = isWindows ? "where opencode" : "which opencode";
const env = isWindows
? { ...process.env, PATH: `${process.env.APPDATA}\\npm;${process.env.PATH}` }
: process.env;
await execAsync(command, { windowsHide: true, env });
return true;
} catch {
return false;
try {
await fs.access(getConfigPath());
return true;
} catch {
return false;
}
}
};