MCPcopy
hub / github.com/colbymchenry/codegraph / extractExtensions

Function extractExtensions

src/project-config.ts:145–164  ·  view source on GitHub ↗

* Validate the `extensions` map. Every failure mode degrades to "no overrides * from this entry" — a bad value or a typo'd language never throws.

(parsed: object, file: string)

Source from the content-addressed store, hash-verified

143 * from this entry" — a bad value or a typo'd language never throws.
144 */
145function extractExtensions(parsed: object, file: string): Record<string, Language> {
146 const exts = (parsed as ProjectConfig).extensions;
147 if (!exts || typeof exts !== 'object' || Array.isArray(exts)) return EMPTY_EXTENSIONS;
148
149 const out: Record<string, Language> = {};
150 for (const [rawKey, rawVal] of Object.entries(exts)) {
151 const key = normalizeExtKey(rawKey);
152 if (!key) {
153 logWarn(`Ignoring extension mapping in ${PROJECT_CONFIG_FILENAME}: "${rawKey}" is not a valid file extension`, { file });
154 continue;
155 }
156 if (typeof rawVal !== 'string' || !isLanguageSupported(rawVal as Language)) {
157 logWarn(`Ignoring extension "${rawKey}" in ${PROJECT_CONFIG_FILENAME}: "${String(rawVal)}" is not a supported language`, { file });
158 continue;
159 }
160 out[key] = rawVal as Language;
161 }
162
163 return Object.keys(out).length > 0 ? out : EMPTY_EXTENSIONS;
164}
165
166/**
167 * Validate the `includeIgnored` patterns: an array of non-empty gitignore-style

Callers 1

parseConfigFunction · 0.85

Calls 3

logWarnFunction · 0.90
isLanguageSupportedFunction · 0.90
normalizeExtKeyFunction · 0.85

Tested by

no test coverage detected