MCPcopy
hub / github.com/claude-code-best/claude-code / parseSettingsFileUncached

Function parseSettingsFileUncached

src/utils/settings/settings.ts:201–231  ·  view source on GitHub ↗
(path: string)

Source from the content-addressed store, hash-verified

199}
200
201function parseSettingsFileUncached(path: string): {
202 settings: SettingsJson | null
203 errors: ValidationError[]
204} {
205 try {
206 const { resolvedPath } = safeResolvePath(getFsImplementation(), path)
207 const content = readFileSync(resolvedPath)
208
209 if (content.trim() === '') {
210 return { settings: {}, errors: [] }
211 }
212
213 const data = safeParseJSON(content, false)
214
215 // Filter invalid permission rules before schema validation so one bad
216 // rule doesn't cause the entire settings file to be rejected.
217 const ruleWarnings = filterInvalidPermissionRules(data, path)
218
219 const result = SettingsSchema().safeParse(data)
220
221 if (!result.success) {
222 const errors = formatZodError(result.error, path)
223 return { settings: null, errors: [...ruleWarnings, ...errors] }
224 }
225
226 return { settings: result.data, errors: ruleWarnings }
227 } catch (error) {
228 handleFileSystemError(error, path)
229 return { settings: null, errors: [] }
230 }
231}
232
233/**
234 * Get the absolute path to the associated file root for a given settings source

Callers 1

parseSettingsFileFunction · 0.85

Calls 7

safeResolvePathFunction · 0.85
getFsImplementationFunction · 0.85
safeParseJSONFunction · 0.85
formatZodErrorFunction · 0.85
handleFileSystemErrorFunction · 0.85
readFileSyncFunction · 0.50

Tested by

no test coverage detected