(text: string, needle: string)
| 23 | |
| 24 | /** The 1-based line of `text` that contains `needle` (exactly one must). */ |
| 25 | const lineOf = (text: string, needle: string): number => { |
| 26 | const at = text.split('\n').map((l, i) => (l.includes(needle) ? i + 1 : 0)).filter(Boolean); |
| 27 | if (at.length !== 1) throw new Error(`${JSON.stringify(needle)} is on ${at.length} lines`); |
| 28 | return at[0]!; |
| 29 | }; |
| 30 | |
| 31 | const COUNTER_HPP = lines( |
| 32 | '#pragma once', |
no test coverage detected