summaryrefslogtreecommitdiff
path: root/packages/core/src/utils/fileUtils.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/core/src/utils/fileUtils.ts')
-rw-r--r--packages/core/src/utils/fileUtils.ts10
1 files changed, 10 insertions, 0 deletions
diff --git a/packages/core/src/utils/fileUtils.ts b/packages/core/src/utils/fileUtils.ts
index d726c053..cb4d333a 100644
--- a/packages/core/src/utils/fileUtils.ts
+++ b/packages/core/src/utils/fileUtils.ts
@@ -17,6 +17,16 @@ const MAX_LINE_LENGTH_TEXT_FILE = 2000;
export const DEFAULT_ENCODING: BufferEncoding = 'utf-8';
/**
+ * Looks up the specific MIME type for a file path.
+ * @param filePath Path to the file.
+ * @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);
+ return typeof lookedUpMime === 'string' ? lookedUpMime : undefined;
+}
+
+/**
* Checks if a path is within a given root directory.
* @param pathToCheck The absolute path to check.
* @param rootDirectory The absolute root directory.