9 lines
406 B
JavaScript
9 lines
406 B
JavaScript
import { mkdirSync, writeFileSync } from 'node:fs'
|
|
import { dirname } from 'node:path'
|
|
|
|
// Indented JSON with a trailing newline: these files end up in git and on a
|
|
// Nextcloud, where a human may well open them in a text editor.
|
|
export function writeJsonFile(filePath, value) {
|
|
mkdirSync(dirname(filePath), { recursive: true })
|
|
writeFileSync(filePath, `${JSON.stringify(value, null, 2)}\n`, 'utf8')
|
|
}
|