(path: string)
| 54 | } |
| 55 | |
| 56 | export async function safeFeadJSONFile(path: string) { |
| 57 | try { |
| 58 | const fileExists = await pathExists(path); |
| 59 | |
| 60 | if (!fileExists) return; |
| 61 | |
| 62 | const fileContents = await readFile(path); |
| 63 | |
| 64 | return JSON.parse(fileContents); |
| 65 | } catch { |
| 66 | return; |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | export async function writeJSONFile(path: string, json: any, pretty = false) { |
| 71 | await writeFile(path, JSON.stringify(json, undefined, pretty ? 2 : undefined), "utf8"); |
nothing calls this directly
no test coverage detected
searching dependent graphs…