( filePath: string, )
| 79 | * Returns null if file doesn't exist or can't be read |
| 80 | */ |
| 81 | export async function readFileLines( |
| 82 | filePath: string, |
| 83 | ): Promise<string[] | null> { |
| 84 | try { |
| 85 | const content = await readFile(filePath, { encoding: 'utf8' }) |
| 86 | return content.split('\n') |
| 87 | } catch (e: unknown) { |
| 88 | if (isFsInaccessible(e)) return null |
| 89 | throw e |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | /** |
| 94 | * Write lines back to a file |
no test coverage detected