Skip to content

Latest commit

 

History

History
18 lines (12 loc) · 549 Bytes

outputJson-sync.md

File metadata and controls

18 lines (12 loc) · 549 Bytes

outputJsonSync(file, data, [options])

Almost the same as writeJsonSync, except that if the directory does not exist, it's created. options are what you'd pass to jsonFile.writeFileSync().

Alias: outputJSONSync()

Example:

const fs = require('fs-extra')

const file = '/tmp/this/path/does/not/exist/file.json'
fs.outputJsonSync(file, {name: 'JP'})

const data = fs.readJsonSync(file)
console.log(data.name) // => JP