( path: string, needle: string, contextLines = 3, )
| 29 | * needle isn't found within MAX_SCAN_BYTES. |
| 30 | */ |
| 31 | export async function readEditContext( |
| 32 | path: string, |
| 33 | needle: string, |
| 34 | contextLines = 3, |
| 35 | ): Promise<EditContext | null> { |
| 36 | const handle = await openForScan(path) |
| 37 | if (handle === null) return null |
| 38 | try { |
| 39 | return await scanForContext(handle, needle, contextLines) |
| 40 | } finally { |
| 41 | await handle.close() |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | /** |
| 46 | * Opens `path` for reading. Returns null on ENOENT. Caller owns close(). |
no test coverage detected