* Check if file-based managed settings (managed-settings.json or any * managed-settings.d/*.json) exist and have content. Cheap sync check * used to skip HKCU when a higher-priority file-based source exists.
()
| 278 | * used to skip HKCU when a higher-priority file-based source exists. |
| 279 | */ |
| 280 | function hasManagedSettingsFile(): boolean { |
| 281 | try { |
| 282 | const filePath = join(getManagedFilePath(), 'managed-settings.json') |
| 283 | const content = readFileSync(filePath) |
| 284 | const data = safeParseJSON(content, false) |
| 285 | if (data && typeof data === 'object' && Object.keys(data).length > 0) { |
| 286 | return true |
| 287 | } |
| 288 | } catch { |
| 289 | // fall through to drop-in check |
| 290 | } |
| 291 | try { |
| 292 | const dropInDir = getManagedSettingsDropInDir() |
| 293 | const entries = getFsImplementation().readdirSync(dropInDir) |
| 294 | for (const d of entries) { |
| 295 | if ( |
| 296 | !(d.isFile() || d.isSymbolicLink()) || |
| 297 | !d.name.endsWith('.json') || |
| 298 | d.name.startsWith('.') |
| 299 | ) { |
| 300 | continue |
| 301 | } |
| 302 | try { |
| 303 | const content = readFileSync(join(dropInDir, d.name)) |
| 304 | const data = safeParseJSON(content, false) |
| 305 | if (data && typeof data === 'object' && Object.keys(data).length > 0) { |
| 306 | return true |
| 307 | } |
| 308 | } catch { |
| 309 | // skip unreadable/malformed file |
| 310 | } |
| 311 | } |
| 312 | } catch { |
| 313 | // drop-in dir doesn't exist |
| 314 | } |
| 315 | return false |
| 316 | } |
| 317 |
no test coverage detected