mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-26 21:14:35 -07:00
feat(core): Download ripgrep at runtime, if enabled. (#7818)
This commit is contained in:
@@ -28,6 +28,7 @@ import {
|
||||
processSingleFileContent,
|
||||
detectBOM,
|
||||
readFileWithEncoding,
|
||||
fileExists,
|
||||
} from './fileUtils.js';
|
||||
import { StandardFileSystemService } from '../services/fileSystemService.js';
|
||||
|
||||
@@ -133,6 +134,25 @@ describe('fileUtils', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('fileExists', () => {
|
||||
it('should return true if the file exists', async () => {
|
||||
const testFile = path.join(tempRootDir, 'exists.txt');
|
||||
actualNodeFs.writeFileSync(testFile, 'content');
|
||||
await expect(fileExists(testFile)).resolves.toBe(true);
|
||||
});
|
||||
|
||||
it('should return false if the file does not exist', async () => {
|
||||
const testFile = path.join(tempRootDir, 'does-not-exist.txt');
|
||||
await expect(fileExists(testFile)).resolves.toBe(false);
|
||||
});
|
||||
|
||||
it('should return true for a directory that exists', async () => {
|
||||
const testDir = path.join(tempRootDir, 'exists-dir');
|
||||
actualNodeFs.mkdirSync(testDir);
|
||||
await expect(fileExists(testDir)).resolves.toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('isBinaryFile', () => {
|
||||
let filePathForBinaryTest: string;
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
import fs from 'node:fs';
|
||||
import fsPromises from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
import type { PartUnion } from '@google/genai';
|
||||
// eslint-disable-next-line import/no-internal-modules
|
||||
@@ -467,3 +468,12 @@ export async function processSingleFileContent(
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function fileExists(filePath: string): Promise<boolean> {
|
||||
try {
|
||||
await fsPromises.access(filePath, fs.constants.F_OK);
|
||||
return true;
|
||||
} catch (_: unknown) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user