| 641 | |
| 642 | /** Reads the content of a text file */ |
| 643 | export function readFileText(filePath: string, encoding: BufferEncoding = "utf8"): Promise<string> { |
| 644 | return new Promise<string>((resolve, reject) => { |
| 645 | fs.readFile(filePath, { encoding }, (err: any, data: any) => { |
| 646 | if (err) { |
| 647 | reject(err); |
| 648 | } else { |
| 649 | resolve(data); |
| 650 | } |
| 651 | }); |
| 652 | }); |
| 653 | } |
| 654 | |
| 655 | /** Writes content to a text file */ |
| 656 | export function writeFileText(filePath: string, content: string, encoding: BufferEncoding = "utf8"): Promise<void> { |