mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-26 21:14:35 -07:00
feat(core): Re-download rg binary if it is deleted. (#8126)
This commit is contained in:
@@ -20,7 +20,7 @@ import { Storage } from '../config/storage.js';
|
||||
|
||||
const DEFAULT_TOTAL_MAX_MATCHES = 20000;
|
||||
|
||||
function getRgPath() {
|
||||
function getRgPath(): string {
|
||||
return path.join(Storage.getGlobalBinDir(), 'rg');
|
||||
}
|
||||
|
||||
@@ -36,6 +36,16 @@ export async function canUseRipgrep(): Promise<boolean> {
|
||||
return await fileExists(getRgPath());
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures `rg` is downloaded, or throws.
|
||||
*/
|
||||
export async function ensureRgPath(): Promise<string> {
|
||||
if (await canUseRipgrep()) {
|
||||
return getRgPath();
|
||||
}
|
||||
throw new Error('Cannot use ripgrep.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Parameters for the GrepTool
|
||||
*/
|
||||
@@ -310,8 +320,9 @@ class GrepToolInvocation extends BaseToolInvocation<
|
||||
rgArgs.push(absolutePath);
|
||||
|
||||
try {
|
||||
const rgPath = await ensureRgPath();
|
||||
const output = await new Promise<string>((resolve, reject) => {
|
||||
const child = spawn(getRgPath(), rgArgs, {
|
||||
const child = spawn(rgPath, rgArgs, {
|
||||
windowsHide: true,
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user