()
| 120 | |
| 121 | /** Read every `*.css` in the overrides dir into a Override (raw text). */ |
| 122 | export async function listOverrides(): Promise<Override[]> { |
| 123 | const dir = getOverridesDir() |
| 124 | let entries: string[] |
| 125 | try { |
| 126 | entries = await fs.readdir(dir) |
| 127 | } catch { |
| 128 | return [] |
| 129 | } |
| 130 | const overrides: Override[] = [] |
| 131 | for (const entry of entries) { |
| 132 | if (!entry.toLowerCase().endsWith('.css')) continue |
| 133 | try { |
| 134 | const css = await fs.readFile(path.join(dir, entry), 'utf8') |
| 135 | overrides.push({ name: entry, css }) |
| 136 | } catch (err) { |
| 137 | overrides.push({ |
| 138 | name: entry, |
| 139 | css: '', |
| 140 | error: err instanceof Error ? err.message : 'Could not read this override.' |
| 141 | }) |
| 142 | } |
| 143 | } |
| 144 | overrides.sort((a, b) => a.name.localeCompare(b.name)) |
| 145 | return overrides |
| 146 | } |
| 147 | |
| 148 | let watcher: ReturnType<typeof chokidar.watch> | null = null |
| 149 |
no test coverage detected