(filepath: string, content: string | object, options: JSONStringifyOptions = {})
| 25 | } |
| 26 | |
| 27 | export function writeJSONSync(filepath: string, content: string | object, options: JSONStringifyOptions = {}) { |
| 28 | options.space = options.space ?? 2; |
| 29 | if (typeof content === 'object') { |
| 30 | content = JSON.stringify(content, options.replacer, options.space) + '\n'; |
| 31 | } |
| 32 | mkdirSync(dirname(filepath), { recursive: true }); |
| 33 | writeFileSync(filepath, content); |
| 34 | } |
| 35 | |
| 36 | export async function readJSON<T = any>(filepath: string): Promise<T> { |
| 37 | const content = await readFile(filepath, 'utf8'); |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…