()
| 125 | * Used by /status to show "(file)", "(drop-ins)", or "(file + drop-ins)". |
| 126 | */ |
| 127 | export function getManagedFileSettingsPresence(): { |
| 128 | hasBase: boolean |
| 129 | hasDropIns: boolean |
| 130 | } { |
| 131 | const { settings: base } = parseSettingsFile(getManagedSettingsFilePath()) |
| 132 | const hasBase = !!base && Object.keys(base).length > 0 |
| 133 | |
| 134 | let hasDropIns = false |
| 135 | const dropInDir = getManagedSettingsDropInDir() |
| 136 | try { |
| 137 | hasDropIns = getFsImplementation() |
| 138 | .readdirSync(dropInDir) |
| 139 | .some( |
| 140 | d => |
| 141 | (d.isFile() || d.isSymbolicLink()) && |
| 142 | d.name.endsWith('.json') && |
| 143 | !d.name.startsWith('.'), |
| 144 | ) |
| 145 | } catch { |
| 146 | // dir doesn't exist |
| 147 | } |
| 148 | |
| 149 | return { hasBase, hasDropIns } |
| 150 | } |
| 151 | |
| 152 | /** |
| 153 | * Handles file system errors appropriately |
no test coverage detected