mirror of
https://github.com/Nezumi-2711/9router.git
synced 2026-09-23 04:09:49 +00:00
Fix bug
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user