(filepath: string)
| 13 | } |
| 14 | |
| 15 | function readJSONFile<T>(filepath: string): Promise<T> { |
| 16 | return ( |
| 17 | readFile(filepath) |
| 18 | // oxlint-disable-next-line typescript/no-unsafe-type-assertion |
| 19 | .then((content) => parseJsonc(content) as T) |
| 20 | .catch((error: unknown) => { |
| 21 | console.error(`Error reading ${filepath}: ${String(error)}`); |
| 22 | throw error; |
| 23 | }) |
| 24 | ); |
| 25 | } |
| 26 | |
| 27 | function fileExists(filepath: string) { |
| 28 | return fs.access(filepath).then( |