(absoluteFilePath: string)
| 597 | // -- |
| 598 | |
| 599 | function readFileForEdit(absoluteFilePath: string): { |
| 600 | content: string |
| 601 | fileExists: boolean |
| 602 | encoding: BufferEncoding |
| 603 | lineEndings: LineEndingType |
| 604 | } { |
| 605 | try { |
| 606 | // eslint-disable-next-line custom-rules/no-sync-fs |
| 607 | const meta = readFileSyncWithMetadata(absoluteFilePath) |
| 608 | return { |
| 609 | content: meta.content, |
| 610 | fileExists: true, |
| 611 | encoding: meta.encoding, |
| 612 | lineEndings: meta.lineEndings, |
| 613 | } |
| 614 | } catch (e) { |
| 615 | if (isENOENT(e)) { |
| 616 | return { |
| 617 | content: '', |
| 618 | fileExists: false, |
| 619 | encoding: 'utf8', |
| 620 | lineEndings: 'LF', |
| 621 | } |
| 622 | } |
| 623 | throw e |
| 624 | } |
| 625 | } |
| 626 |
no test coverage detected