mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-29 14:34:55 -07:00
Reduce bundle size & check it in CI (#7395)
This commit is contained in:
@@ -7,7 +7,8 @@
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import type { PartUnion } from '@google/genai';
|
||||
import mime from 'mime-types';
|
||||
// eslint-disable-next-line import/no-internal-modules
|
||||
import mime from 'mime/lite';
|
||||
import type { FileSystemService } from '../services/fileSystemService.js';
|
||||
import { ToolErrorType } from '../tools/tool-error.js';
|
||||
import { BINARY_EXTENSIONS } from './ignorePatterns.js';
|
||||
@@ -157,7 +158,7 @@ export async function readFileWithEncoding(filePath: string): Promise<string> {
|
||||
* @returns The specific MIME type string (e.g., 'text/python', 'application/javascript') or undefined if not found or ambiguous.
|
||||
*/
|
||||
export function getSpecificMimeType(filePath: string): string | undefined {
|
||||
const lookedUpMime = mime.lookup(filePath);
|
||||
const lookedUpMime = mime.getType(filePath);
|
||||
return typeof lookedUpMime === 'string' ? lookedUpMime : undefined;
|
||||
}
|
||||
|
||||
@@ -261,7 +262,7 @@ export async function detectFileType(
|
||||
return 'svg';
|
||||
}
|
||||
|
||||
const lookedUpMimeType = mime.lookup(filePath); // Returns false if not found, or the mime type string
|
||||
const lookedUpMimeType = mime.getType(filePath); // Returns null if not found, or the mime type string
|
||||
if (lookedUpMimeType) {
|
||||
if (lookedUpMimeType.startsWith('image/')) {
|
||||
return 'image';
|
||||
@@ -437,7 +438,7 @@ export async function processSingleFileContent(
|
||||
llmContent: {
|
||||
inlineData: {
|
||||
data: base64Data,
|
||||
mimeType: mime.lookup(filePath) || 'application/octet-stream',
|
||||
mimeType: mime.getType(filePath) || 'application/octet-stream',
|
||||
},
|
||||
},
|
||||
returnDisplay: `Read ${fileType} file: ${relativePathForDisplay}`,
|
||||
|
||||
Reference in New Issue
Block a user