MCPcopy Create free account
hub / github.com/Noumena-Network/code / loadManagedFileSettings

Function loadManagedFileSettings

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

Source from the content-addressed store, hash-verified

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

Callers 3

getPolicySettingsOriginFunction · 0.85
loadSettingsFromDiskFunction · 0.85

Calls 6

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

Tested by

no test coverage detected