(file: string, text: string)
| 32 | } |
| 33 | |
| 34 | export function findCodeFromString(file: string, text: string): Hit[] { |
| 35 | const hits: Hit[] = []; |
| 36 | for (const m of text.matchAll(CODE_FROM_STRING)) { |
| 37 | const at = m.index ?? 0; |
| 38 | hits.push({ file, index: at, excerpt: text.slice(Math.max(0, at - 30), at + 50) }); |
| 39 | } |
| 40 | return hits; |
| 41 | } |
| 42 | |
| 43 | /** Every file under `dir`, recursively, with a path relative to `dir`. */ |
| 44 | export function walk(dir: string, rel = ''): string[] { |
no test coverage detected