fix(extensions): support Windows npm global paths for Gemini CLI
This commit is contained in:
parent
b6a3a91edf
commit
80302c4e12
@ -64,13 +64,27 @@ export function extractGeminiCliCredentials(): { clientId: string; clientSecret:
|
|||||||
if (!geminiPath) return null;
|
if (!geminiPath) return null;
|
||||||
|
|
||||||
const resolvedPath = realpathSync(geminiPath);
|
const resolvedPath = realpathSync(geminiPath);
|
||||||
const geminiCliDir = dirname(dirname(resolvedPath));
|
|
||||||
|
// Support both Unix symlinks and Windows npm shims
|
||||||
const searchPaths = [
|
const bases = [
|
||||||
join(geminiCliDir, "node_modules", "@google", "gemini-cli-core", "dist", "src", "code_assist", "oauth2.js"),
|
dirname(dirname(resolvedPath)), // Unix: .../pkg/bin/run -> .../pkg
|
||||||
join(geminiCliDir, "node_modules", "@google", "gemini-cli-core", "dist", "code_assist", "oauth2.js"),
|
dirname(resolvedPath), // Windows: .../npm/gemini.cmd -> .../npm
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const searchPaths: string[] = [];
|
||||||
|
for (const base of bases) {
|
||||||
|
// 1. Check for flat installation of gemini-cli-core
|
||||||
|
searchPaths.push(
|
||||||
|
join(base, "node_modules", "@google", "gemini-cli-core", "dist", "src", "code_assist", "oauth2.js"),
|
||||||
|
join(base, "node_modules", "@google", "gemini-cli-core", "dist", "code_assist", "oauth2.js")
|
||||||
|
);
|
||||||
|
// 2. Check for nested installation inside gemini-cli
|
||||||
|
searchPaths.push(
|
||||||
|
join(base, "node_modules", "@google", "gemini-cli", "node_modules", "@google", "gemini-cli-core", "dist", "src", "code_assist", "oauth2.js"),
|
||||||
|
join(base, "node_modules", "@google", "gemini-cli", "node_modules", "@google", "gemini-cli-core", "dist", "code_assist", "oauth2.js")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
let content: string | null = null;
|
let content: string | null = null;
|
||||||
for (const p of searchPaths) {
|
for (const p of searchPaths) {
|
||||||
if (existsSync(p)) {
|
if (existsSync(p)) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user