( filename: string, encoding: BufferEncoding = "utf-8", )
| 5 | } |
| 6 | |
| 7 | export function readFile( |
| 8 | filename: string, |
| 9 | encoding: BufferEncoding = "utf-8", |
| 10 | ): string { |
| 11 | try { |
| 12 | return fs.readFileSync(filename, encoding); |
| 13 | } catch (error) { |
| 14 | if (isFsError(error) && error.code === "ENOENT") { |
| 15 | console.error(`Not found: "${filename}"`); |
| 16 | process.exit(1); |
| 17 | } else { |
| 18 | throw error; |
| 19 | } |
| 20 | } |
| 21 | } |
| 22 | |
| 23 | function isFsError(error: unknown): error is { code: string } { |
| 24 | return ( |
no test coverage detected
searching dependent graphs…