MCPcopy
hub / github.com/codeaashu/claude-code / loadManagedFileSettings

Function loadManagedFileSettings

src/utils/settings/settings.ts:74–121  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

72 * Exported for testing.
73 */
74export function loadManagedFileSettings(): {
75 settings: SettingsJson | null
76 errors: ValidationError[]
77} {
78 const errors: ValidationError[] = []
79 let merged: SettingsJson = {}
80 let found = false
81
82 const { settings, errors: baseErrors } = parseSettingsFile(
83 getManagedSettingsFilePath(),
84 )
85 errors.push(...baseErrors)
86 if (settings && Object.keys(settings).length > 0) {
87 merged = mergeWith(merged, settings, settingsMergeCustomizer)
88 found = true
89 }
90
91 const dropInDir = getManagedSettingsDropInDir()
92 try {
93 const entries = getFsImplementation()
94 .readdirSync(dropInDir)
95 .filter(
96 d =>
97 (d.isFile() || d.isSymbolicLink()) &&
98 d.name.endsWith('.json') &&
99 !d.name.startsWith('.'),
100 )
101 .map(d => d.name)
102 .sort()
103 for (const name of entries) {
104 const { settings, errors: fileErrors } = parseSettingsFile(
105 join(dropInDir, name),
106 )
107 errors.push(...fileErrors)
108 if (settings && Object.keys(settings).length > 0) {
109 merged = mergeWith(merged, settings, settingsMergeCustomizer)
110 found = true
111 }
112 }
113 } catch (e) {
114 const code = getErrnoCode(e)
115 if (code !== 'ENOENT' && code !== 'ENOTDIR') {
116 logError(e)
117 }
118 }
119
120 return { settings: found ? merged : null, errors }
121}
122
123/**
124 * Check which file-based managed settings sources are present.

Callers 3

getPolicySettingsOriginFunction · 0.85
loadSettingsFromDiskFunction · 0.85

Calls 7

parseSettingsFileFunction · 0.85
getFsImplementationFunction · 0.85
getErrnoCodeFunction · 0.85
keysMethod · 0.80
logErrorFunction · 0.50
pushMethod · 0.45

Tested by

no test coverage detected