Skip to content

@vtj


@vtj / node / outputJsonSync

Variable: outputJsonSync() ​

const outputJsonSync: (file, data, options?) => void = fs.outputJsonSync

Defined in: packages/node/src/fs.ts:25

Almost the same as writeJsonSync, except that if the directory does not exist, it's created.

Parameters ​

file ​

string

data ​

any

options? ​

JsonOutputOptions

Returns ​

void

Example ​

ts
import * as fs from '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